Merge ~cjwatson/launchpad:py3-bytes-formatting into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 5e468ef2e57625b76d9e74869216b604baa9a57b
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-bytes-formatting
Merge into: launchpad:master
Diff against target: 613 lines (+83/-84)
14 files modified
lib/lp/app/browser/doc/launchpad-search-pages.txt (+6/-7)
lib/lp/archivepublisher/tests/test_sync_signingkeys.py (+14/-14)
lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt (+4/-4)
lib/lp/buildmaster/tests/mock_slaves.py (+1/-1)
lib/lp/services/daemons/tests/test_tachandler.py (+2/-2)
lib/lp/services/librarianserver/doc/upload.txt (+3/-3)
lib/lp/soyuz/scripts/tests/test_copypackage.py (+3/-3)
lib/lp/soyuz/stories/ppa/xx-ppa-files.txt (+12/-12)
lib/lp/translations/doc/poimport-pofile-old-po-imported.txt (+4/-4)
lib/lp/translations/doc/poimport-pofile-syntax-error.txt (+12/-12)
lib/lp/translations/doc/poimport.txt (+10/-10)
lib/lp/translations/doc/rosetta-karma.txt (+4/-4)
lib/lp/translations/doc/rosetta-poimport-script.txt (+6/-6)
lib/lp/translations/utilities/tests/test_translation_importer.py (+2/-2)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+398874@code.launchpad.net

Commit message

Avoid b"%s" % str constructions

Description of the change

On Python 3, %s in a bytes format string requires bytes.

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/app/browser/doc/launchpad-search-pages.txt b/lib/lp/app/browser/doc/launchpad-search-pages.txt
2index ded7f0d..abc6e37 100644
3--- a/lib/lp/app/browser/doc/launchpad-search-pages.txt
4+++ b/lib/lp/app/browser/doc/launchpad-search-pages.txt
5@@ -39,11 +39,10 @@ When text is not None, the title indicates what was searched.
6 ... search_param_list = []
7 ... for name in sorted(form):
8 ... value = form[name]
9- ... if isinstance(value, six.text_type):
10- ... value = wsgi_native_string(value)
11- ... search_param_list.append(b'%s=%s' % (
12- ... wsgi_native_string(name), value))
13- ... query_string = b'&'.join(search_param_list)
14+ ... search_param_list.append(
15+ ... wsgi_native_string(name) + wsgi_native_string('=') +
16+ ... wsgi_native_string(value))
17+ ... query_string = wsgi_native_string('&').join(search_param_list)
18 ... request = LaunchpadTestRequest(
19 ... SERVER_URL='https://launchpad.test/+search',
20 ... QUERY_STRING=query_string, form=form, PATH_INFO='/+search')
21@@ -129,7 +128,7 @@ created because they are the owner.
22 ... owner=sample_person, information_type=InformationType.USERDATA)
23
24 >>> search_view = getSearchView(
25- ... form={'field.text': private_bug.id})
26+ ... form={'field.text': str(private_bug.id)})
27 >>> search_view.bug.private
28 True
29
30@@ -137,7 +136,7 @@ But anonymous and unprivileged users cannot see the private bug.
31
32 >>> login(ANONYMOUS)
33 >>> search_view = getSearchView(
34- ... form={'field.text': private_bug.id})
35+ ... form={'field.text': str(private_bug.id)})
36 >>> print(search_view.bug)
37 None
38
39diff --git a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
40index 7c54063..9e4189c 100644
41--- a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
42+++ b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
43@@ -209,20 +209,20 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
44
45 # Create fake UEFI keys for the root
46 for filename in ("uefi.key", "uefi.crt"):
47- with open(os.path.join(archive_root, filename), 'wb') as fd:
48- fd.write(b"Root %s" % filename)
49+ with open(os.path.join(archive_root, filename), 'w') as fd:
50+ fd.write("Root %s" % filename)
51
52 # Create fake OPAL and Kmod keys for series1
53 for filename in ("opal.pem", "opal.x509", "kmod.pem", "kmod.x509"):
54- with open(os.path.join(key_dirs[series1], filename), 'wb') as fd:
55- fd.write(b"Series 1 %s" % filename)
56+ with open(os.path.join(key_dirs[series1], filename), 'w') as fd:
57+ fd.write("Series 1 %s" % filename)
58
59 # Create fake FIT keys for series1
60 os.makedirs(os.path.join(key_dirs[series1], "fit"))
61 for filename in ("fit.key", "fit.crt"):
62 with open(os.path.join(key_dirs[series1], "fit", filename),
63- 'wb') as fd:
64- fd.write(b"Series 1 %s" % filename)
65+ 'w') as fd:
66+ fd.write("Series 1 %s" % filename)
67
68 script = self.makeScript(["--archive", archive.reference])
69 script.inject = mock.Mock()
70@@ -304,20 +304,20 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
71
72 # Create fake UEFI keys for the root
73 for filename in ("uefi.key", "uefi.crt"):
74- with open(os.path.join(archive_root, filename), 'wb') as fd:
75- fd.write(b"Root %s" % filename)
76+ with open(os.path.join(archive_root, filename), 'w') as fd:
77+ fd.write("Root %s" % filename)
78
79 # Create fake OPAL and Kmod keys for series1
80 for filename in ("opal.pem", "opal.x509", "kmod.pem", "kmod.x509"):
81- with open(os.path.join(key_dirs[series1], filename), 'wb') as fd:
82- fd.write(b"Series 1 %s" % filename)
83+ with open(os.path.join(key_dirs[series1], filename), 'w') as fd:
84+ fd.write("Series 1 %s" % filename)
85
86 # Create fake FIT keys for series1
87 os.makedirs(os.path.join(key_dirs[series1], "fit"))
88 for filename in ("fit.key", "fit.crt"):
89 with open(os.path.join(key_dirs[series1], "fit", filename),
90- 'wb') as fd:
91- fd.write(b"Series 1 %s" % filename)
92+ 'w') as fd:
93+ fd.write("Series 1 %s" % filename)
94
95 script = self.makeScript(
96 ["--archive", archive.reference, "--overwrite", "--dry-run"])
97@@ -385,8 +385,8 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
98 gpgkey = self.factory.makeGPGKey(archive.owner)
99 secret_key_path = os.path.join(
100 self.signing_root_dir, "%s.gpg" % gpgkey.fingerprint)
101- with open(secret_key_path, "wb") as fd:
102- fd.write(b"Private key %s" % gpgkey.fingerprint)
103+ with open(secret_key_path, "w") as fd:
104+ fd.write("Private key %s" % gpgkey.fingerprint)
105 archive.signing_key_owner = archive.owner
106 archive.signing_key_fingerprint = gpgkey.fingerprint
107
108diff --git a/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt b/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt
109index 1647a69..ba8dda6 100644
110--- a/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt
111+++ b/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-tools.txt
112@@ -66,10 +66,10 @@ The most common case will be that the user is sent to the guided
113 >>> filebug_path = (
114 ... '/ubuntu/+source/mozilla-firefox/+filebug/%s' % blob_token)
115 >>> filebug_url = 'http://%s%s' % (filebug_host, filebug_path)
116- >>> contents = str(http(
117- ... b"GET %s HTTP/1.1\nHostname: %s\n"
118- ... b"Authorization: Basic test@canonical.com:test\n\n"
119- ... % (filebug_path, filebug_host)))
120+ >>> contents = str(http(six.ensure_binary(
121+ ... "GET %s HTTP/1.1\nHostname: %s\n"
122+ ... "Authorization: Basic test@canonical.com:test\n\n"
123+ ... % (filebug_path, filebug_host))))
124
125 At first, the user will be shown a message telling them that the extra
126 data is being processed.
127diff --git a/lib/lp/buildmaster/tests/mock_slaves.py b/lib/lp/buildmaster/tests/mock_slaves.py
128index 6fb0049..7e19f5b 100644
129--- a/lib/lp/buildmaster/tests/mock_slaves.py
130+++ b/lib/lp/buildmaster/tests/mock_slaves.py
131@@ -217,7 +217,7 @@ class WaitingSlave(OkSlave):
132 if isinstance(file_to_write, six.string_types):
133 file_to_write = open(file_to_write, 'wb')
134 if not self.valid_files[hash]:
135- content = b"This is a %s" % hash
136+ content = ("This is a %s" % hash).encode("ASCII")
137 else:
138 with open(self.valid_files[hash], 'rb') as source:
139 content = source.read()
140diff --git a/lib/lp/services/daemons/tests/test_tachandler.py b/lib/lp/services/daemons/tests/test_tachandler.py
141index 75d45a7..0b01898 100644
142--- a/lib/lp/services/daemons/tests/test_tachandler.py
143+++ b/lib/lp/services/daemons/tests/test_tachandler.py
144@@ -169,7 +169,7 @@ class TacTestSetupTestCase(testtools.TestCase):
145 with open(fixture.logfile, "wb") as logfile:
146 logfile.write(b"One\n")
147 logfile.write(b"Two\n")
148- logfile.write(b"Three, %s\n" % LOG_MAGIC.encode("UTF-8"))
149+ logfile.write(("Three, %s\n" % LOG_MAGIC).encode("UTF-8"))
150 logfile.write(b"Four\n")
151
152 # Truncating the log leaves everything up to and including the line
153@@ -177,5 +177,5 @@ class TacTestSetupTestCase(testtools.TestCase):
154 fixture.truncateLog()
155 with open(fixture.logfile, "rb") as logfile:
156 self.assertEqual(
157- b"One\nTwo\nThree, %s\n" % LOG_MAGIC.encode("UTF-8"),
158+ ("One\nTwo\nThree, %s\n" % LOG_MAGIC).encode("UTF-8"),
159 logfile.read())
160diff --git a/lib/lp/services/librarianserver/doc/upload.txt b/lib/lp/services/librarianserver/doc/upload.txt
161index ca8c26a..595b0b7 100644
162--- a/lib/lp/services/librarianserver/doc/upload.txt
163+++ b/lib/lp/services/librarianserver/doc/upload.txt
164@@ -108,13 +108,13 @@ Filename with spaces work.
165
166 Unicode filenames work, but must be encoded as UTF-8 on the socket.
167
168- >>> filename = 'Yow\N{INTERROBANG}'.encode('utf-8')
169- >>> upload_request(b"""STORE 14 %s
170+ >>> filename = 'Yow\N{INTERROBANG}'
171+ >>> upload_request(("""STORE 14 %s
172 ... Content-Type: text/plain
173 ... File-Content-ID: 123
174 ... File-Alias-ID: 456
175 ... Database-Name: right_database
176 ...
177- ... Cats and dogs.""" % filename)
178+ ... Cats and dogs.""" % filename).encode('UTF-8'))
179 reply: '200'
180 file 'Yow‽' stored as text/plain, contents: 'Cats and dogs.'
181diff --git a/lib/lp/soyuz/scripts/tests/test_copypackage.py b/lib/lp/soyuz/scripts/tests/test_copypackage.py
182index 8fdf14e..1bce73c 100644
183--- a/lib/lp/soyuz/scripts/tests/test_copypackage.py
184+++ b/lib/lp/soyuz/scripts/tests/test_copypackage.py
185@@ -2068,9 +2068,9 @@ class TestCopyClosesBugs(TestCaseWithFactory):
186
187 def createSource(self, version, archive, pocket, bug_id):
188 changes_template = (
189- b"Format: 1.7\n"
190- b"Launchpad-bugs-fixed: %s\n")
191- changes_file_content = changes_template % bug_id
192+ "Format: 1.7\n"
193+ "Launchpad-bugs-fixed: %s\n")
194+ changes_file_content = (changes_template % bug_id).encode("UTF-8")
195 source = self.test_publisher.getPubSource(
196 sourcename='buggy-source', version=version,
197 distroseries=self.hoary_test, archive=archive, pocket=pocket,
198diff --git a/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt b/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt
199index f4ad646..ca2e9a1 100644
200--- a/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt
201+++ b/lib/lp/soyuz/stories/ppa/xx-ppa-files.txt
202@@ -251,10 +251,10 @@ Sample Person can't access the file.
203
204 The 'No Privileges' user, the PPA owner, can download the DSC file.
205
206- >>> print(http(br"""
207+ >>> print(http(six.ensure_binary(r"""
208 ... GET %s HTTP/1.1
209 ... Authorization: Basic no-priv@canonical.com:test
210- ... """ % (dsc_file_lp_url.replace('http://launchpad.test', ''))))
211+ ... """ % (dsc_file_lp_url.replace('http://launchpad.test', '')))))
212 HTTP/1.1 303 See Other
213 ...
214 Location: https://...restricted.../test-pkg_1.0.dsc?token=...
215@@ -272,10 +272,10 @@ Binary files are served via '+files' rather than '+sourcefiles'.
216 Traceback (most recent call last):
217 ...
218 zope.security.interfaces.Unauthorized
219- >>> print(http(br"""
220+ >>> print(http(six.ensure_binary(r"""
221 ... GET %s HTTP/1.1
222 ... Authorization: Basic no-priv@canonical.com:test
223- ... """ % (deb_file_lp_url.replace('http://launchpad.test', ''))))
224+ ... """ % (deb_file_lp_url.replace('http://launchpad.test', '')))))
225 HTTP/1.1 303 See Other
226 ...
227 Location: https://...restricted.../test-bin_1.0_all.deb?token=...
228@@ -314,9 +314,9 @@ binaries across to no-priv's public ppa.
229 >>> print(file_librarian_url)
230 http://.../test-pkg_1.0.dsc
231
232- >>> print(http(br"""
233+ >>> print(http(six.ensure_binary(r"""
234 ... GET %s HTTP/1.1
235- ... """ % file_lp_url.replace('http://launchpad.test', '')))
236+ ... """ % file_lp_url.replace('http://launchpad.test', ''))))
237 HTTP/1.1 303 See Other
238 ...
239 Location: http://.../test-pkg_1.0.dsc
240@@ -341,10 +341,10 @@ redirect to the files for the default named PPA.
241 >>> file_lp_url_without_ppa_name = (
242 ... 'http://launchpad.test/~no-priv/+archive/+files/test-pkg_1.0.dsc')
243
244- >>> print(http(br"""
245+ >>> print(http(six.ensure_binary(r"""
246 ... GET %s HTTP/1.1
247 ... """ % file_lp_url_without_ppa_name.replace(
248- ... 'http://launchpad.test', '')))
249+ ... 'http://launchpad.test', ''))))
250 HTTP/1.1 301 Moved Permanently
251 ...
252 Location: http://localhost/~no-priv/+archive/ubuntu/ppa/+files/test-pkg_1.0.dsc
253@@ -354,10 +354,10 @@ The same redirection happens for +archive/+build/blah urls:
254
255 >>> buildlog_lp_url_without_ppa_name = (
256 ... 'http://launchpad.test/~no-priv/+archive/+build/1/+files/foo')
257- >>> print(http(br"""
258+ >>> print(http(six.ensure_binary(r"""
259 ... GET %s HTTP/1.1
260 ... """ % buildlog_lp_url_without_ppa_name.replace(
261- ... 'http://launchpad.test', '')))
262+ ... 'http://launchpad.test', ''))))
263 HTTP/1.1 301 Moved Permanently
264 ...
265 Location: http://.../~no-priv/+archive/ubuntu/ppa/+build/1/+files/...
266@@ -411,9 +411,9 @@ LP proxy URL a proper NotFound error is raised.
267 >>> print(file_lp_url)
268 http://launchpad.test/~no-priv/+archive/ubuntu/ppa/+sourcefiles/test-pkg/1.0/test-pkg_1.0.dsc
269
270- >>> not_found_file = http(br"""
271+ >>> not_found_file = http(six.ensure_binary(r"""
272 ... GET %s HTTP/1.1
273- ... """ % file_lp_url.replace('http://launchpad.test', ''))
274+ ... """ % file_lp_url.replace('http://launchpad.test', '')))
275
276 It results in a 404 response.
277
278diff --git a/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt b/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt
279index b49a677..d9a96cc 100644
280--- a/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt
281+++ b/lib/lp/translations/doc/poimport-pofile-old-po-imported.txt
282@@ -62,7 +62,7 @@ We create the POFile object where we are going to attach the .po file.
283
284 First, we do a valid import.
285
286- >>> pofile_contents = br'''
287+ >>> pofile_contents = six.ensure_binary(r'''
288 ... msgid ""
289 ... msgstr ""
290 ... "PO-Revision-Date: 2005-05-03 20:41+0100\n"
291@@ -74,7 +74,7 @@ First, we do a valid import.
292 ...
293 ... msgid "foo"
294 ... msgstr "blah"
295- ... ''' % datetime.datetime.now(UTC).isoformat()
296+ ... ''' % datetime.datetime.now(UTC).isoformat())
297 >>> by_maintainer = False
298 >>> entry = translation_import_queue.addOrUpdateEntry(
299 ... pofile.path, pofile_contents, by_maintainer, person,
300@@ -110,7 +110,7 @@ file we just imported.
301 Now, we are going to import a .po file that has a 'PO-Revision-Date'
302 field with a date older than a previous .po import.
303
304- >>> pofile_contents = br'''
305+ >>> pofile_contents = six.ensure_binary(r'''
306 ... msgid ""
307 ... msgstr ""
308 ... "PO-Revision-Date: 2005-05-03 19:41+0100\n"
309@@ -122,7 +122,7 @@ field with a date older than a previous .po import.
310 ...
311 ... msgid "foo"
312 ... msgstr "blah"
313- ... ''' % datetime.datetime.now(UTC).isoformat()
314+ ... ''' % datetime.datetime.now(UTC).isoformat())
315 >>> by_maintainer = False
316 >>> entry = translation_import_queue.addOrUpdateEntry(
317 ... pofile.path, pofile_contents, by_maintainer, person,
318diff --git a/lib/lp/translations/doc/poimport-pofile-syntax-error.txt b/lib/lp/translations/doc/poimport-pofile-syntax-error.txt
319index 44ce5f5..bc89865 100644
320--- a/lib/lp/translations/doc/poimport-pofile-syntax-error.txt
321+++ b/lib/lp/translations/doc/poimport-pofile-syntax-error.txt
322@@ -58,7 +58,7 @@ We create the POFile object where we are going to attach the .po file.
323 Let's import a .po file that misses the '"' char after msgstr. That's a
324 syntax error.
325
326- >>> pofile_contents = br'''
327+ >>> pofile_contents = six.ensure_binary(r'''
328 ... msgid ""
329 ... msgstr ""
330 ... "PO-Revision-Date: 2005-06-03 20:41+0100\n"
331@@ -70,7 +70,7 @@ syntax error.
332 ...
333 ... msgid "foo"
334 ... msgstr blah"
335- ... ''' % datetime.datetime.now(UTC).isoformat()
336+ ... ''' % datetime.datetime.now(UTC).isoformat())
337 >>> by_maintainer = False
338 >>> entry = translation_import_queue.addOrUpdateEntry(
339 ... pofile.path, pofile_contents, by_maintainer, person,
340@@ -194,7 +194,7 @@ In his rush to be the first Sumerian translator for Firefox, Mark
341 submits a translation with a nonsensical plurals definition.
342
343 >>> pofile = potemplate.newPOFile('sux')
344- >>> pofile_contents = br'''
345+ >>> pofile_contents = six.ensure_binary(r'''
346 ... msgid ""
347 ... msgstr ""
348 ... "PO-Revision-Date: 2005-06-29 11:44+0100\n"
349@@ -205,7 +205,7 @@ submits a translation with a nonsensical plurals definition.
350 ...
351 ... msgid "foo"
352 ... msgstr "bar"
353- ... ''' % datetime.datetime.now(UTC).isoformat()
354+ ... ''' % datetime.datetime.now(UTC).isoformat())
355 >>> entry = translation_import_queue.addOrUpdateEntry(
356 ... pofile.path, pofile_contents, False, person,
357 ... productseries=series, potemplate=potemplate, pofile=pofile)
358@@ -238,7 +238,7 @@ Not enough forms
359 Mark mistakenly attempts to import a translation with "zero" plural
360 forms. He receives an email notifying him of a syntax error.
361
362- >>> pofile_contents = br'''
363+ >>> pofile_contents = six.ensure_binary(r'''
364 ... msgid ""
365 ... msgstr ""
366 ... "PO-Revision-Date: 2005-06-14 18:33+0100\n"
367@@ -249,7 +249,7 @@ forms. He receives an email notifying him of a syntax error.
368 ...
369 ... msgid "foo"
370 ... msgstr "bar"
371- ... ''' % datetime.datetime.now(UTC).isoformat()
372+ ... ''' % datetime.datetime.now(UTC).isoformat())
373 >>> entry = translation_import_queue.addOrUpdateEntry(
374 ... pofile.path, pofile_contents, False, person,
375 ... productseries=series, potemplate=potemplate, pofile=pofile)
376@@ -276,7 +276,7 @@ forms. He receives an email notifying him of a syntax error.
377 On his next attempt, Mark accidentally types a negative number of plural
378 forms. The same error is given.
379
380- >>> pofile_contents = br'''
381+ >>> pofile_contents = six.ensure_binary(r'''
382 ... msgid ""
383 ... msgstr ""
384 ... "PO-Revision-Date: 2005-06-15 19:04+0100\n"
385@@ -287,7 +287,7 @@ forms. The same error is given.
386 ...
387 ... msgid "foo"
388 ... msgstr "bar"
389- ... ''' % datetime.datetime.now(UTC).isoformat()
390+ ... ''' % datetime.datetime.now(UTC).isoformat())
391 >>> entry = translation_import_queue.addOrUpdateEntry(
392 ... pofile.path, pofile_contents, False, person,
393 ... productseries=series, potemplate=potemplate, pofile=pofile)
394@@ -325,7 +325,7 @@ to get that information corrected if need be.
395 >>> pofile = potemplate.newPOFile('ar')
396
397 # PO file with nplurals=7, a value we can't handle.
398- >>> pofile_contents = br'''
399+ >>> pofile_contents = six.ensure_binary(r'''
400 ... msgid ""
401 ... msgstr ""
402 ... "PO-Revision-Date: 2005-07-01 08:35+0100\n"
403@@ -343,7 +343,7 @@ to get that information corrected if need be.
404 ... msgstr[4] "baros %%d"
405 ... msgstr[5] "barorum %%d"
406 ... msgstr[6] "barim %%d"
407- ... ''' % datetime.datetime.now(UTC).isoformat()
408+ ... ''' % datetime.datetime.now(UTC).isoformat())
409 >>> entry = translation_import_queue.addOrUpdateEntry(
410 ... pofile.path, pofile_contents, False, person,
411 ... productseries=series, potemplate=potemplate, pofile=pofile)
412@@ -389,7 +389,7 @@ Once Mark has checked the language page and corrected the number of
413 plural forms, the file imports just fine.
414
415 # Same PO file as before, but with nplurals=6.
416- >>> pofile_contents = br'''
417+ >>> pofile_contents = six.ensure_binary(r'''
418 ... msgid ""
419 ... msgstr ""
420 ... "PO-Revision-Date: 2005-07-01 08:35+0100\n"
421@@ -406,7 +406,7 @@ plural forms, the file imports just fine.
422 ... msgstr[3] "baribus %%d"
423 ... msgstr[4] "baros %%d"
424 ... msgstr[5] "barorum %%d"
425- ... ''' % datetime.datetime.now(UTC).isoformat()
426+ ... ''' % datetime.datetime.now(UTC).isoformat())
427 >>> entry = translation_import_queue.addOrUpdateEntry(
428 ... pofile.path, pofile_contents, False, person,
429 ... productseries=series, potemplate=potemplate, pofile=pofile)
430diff --git a/lib/lp/translations/doc/poimport.txt b/lib/lp/translations/doc/poimport.txt
431index 1c49a97..5b07995 100644
432--- a/lib/lp/translations/doc/poimport.txt
433+++ b/lib/lp/translations/doc/poimport.txt
434@@ -56,7 +56,7 @@ And this is the POTemplate where the import will be done.
435
436 This is the file that'll get imported.
437
438- >>> potemplate_contents = br'''
439+ >>> potemplate_contents = six.ensure_binary(r'''
440 ... msgid ""
441 ... msgstr ""
442 ... "POT-Creation-Date: 2004-07-11 16:16+0900\n"
443@@ -86,7 +86,7 @@ This is the file that'll get imported.
444 ...
445 ... msgid "translator-credits"
446 ... msgstr ""
447- ... ''' % datetime.datetime.now(UTC).isoformat()
448+ ... ''' % datetime.datetime.now(UTC).isoformat())
449
450 We sometimes saw deadlocks as POFile statistics were updated after
451 importing a template. The operation would read all translation messages
452@@ -226,7 +226,7 @@ Import With Errors
453 Here are the contents of the file we'll be importing. It has some
454 validation errors.
455
456- >>> pofile_with_errors = br'''
457+ >>> pofile_with_errors = six.ensure_binary(r'''
458 ... msgid ""
459 ... msgstr ""
460 ... "PO-Revision-Date: 2005-06-03 19:41+0100\n"
461@@ -257,7 +257,7 @@ validation errors.
462 ... msgstr[1] "Bars %%d"
463 ... msgstr[2] "Welsh power! %%d"
464 ... msgstr[3] "We have four! %%d"
465- ... ''' % datetime.datetime.now(UTC).isoformat()
466+ ... ''' % datetime.datetime.now(UTC).isoformat())
467
468 This is the dbschema that controls the validation of a translation.
469
470@@ -423,7 +423,7 @@ instance) and they don't mean that any messages failed to import.
471
472 For example, here's a gettext PO file with two headers.
473
474- >>> pofile_with_warning = br'''
475+ >>> pofile_with_warning = six.ensure_binary(r'''
476 ... msgid ""
477 ... msgstr ""
478 ... "Content-Type: text/plain; charset=UTF-8\n"
479@@ -439,7 +439,7 @@ For example, here's a gettext PO file with two headers.
480 ...
481 ... msgid "a"
482 ... msgstr "b"
483- ... ''' % datetime.datetime.now(UTC).isoformat()
484+ ... ''' % datetime.datetime.now(UTC).isoformat())
485 >>> eo_pofile = potemplate.newPOFile('eo')
486 >>> warning_entry = translation_import_queue.addOrUpdateEntry(
487 ... 'eo.po', pofile_with_warning, False, potemplate.owner,
488@@ -484,7 +484,7 @@ Import Without Errors
489 Now, let's import one without errors. This file changes one translation
490 and adds another one.
491
492- >>> pofile_without_errors = br'''
493+ >>> pofile_without_errors = six.ensure_binary(r'''
494 ... msgid ""
495 ... msgstr ""
496 ... "PO-Revision-Date: 2005-06-03 20:41+0100\n"
497@@ -502,7 +502,7 @@ and adds another one.
498 ...
499 ... msgid "translator-credits"
500 ... msgstr "helpful@example.com"
501- ... ''' % datetime.datetime.now(UTC).isoformat()
502+ ... ''' % datetime.datetime.now(UTC).isoformat())
503 >>> entry = translation_import_queue.addOrUpdateEntry(
504 ... pofile.path, pofile_without_errors, True, rosetta_experts,
505 ... distroseries=distroseries, sourcepackagename=sourcepackagename,
506@@ -645,7 +645,7 @@ plural forms).
507
508 We'll import a POFile with 3 plural forms into this POFile:
509
510- >>> pofile_with_plurals = br'''
511+ >>> pofile_with_plurals = six.ensure_binary(r'''
512 ... msgid ""
513 ... msgstr ""
514 ... "PO-Revision-Date: 2005-06-03 19:41+0100\n"
515@@ -660,7 +660,7 @@ We'll import a POFile with 3 plural forms into this POFile:
516 ... msgstr[0] "First form %%d"
517 ... msgstr[1] "Second form %%d"
518 ... msgstr[2] "Third form %%d"
519- ... ''' % datetime.datetime.now(UTC).isoformat()
520+ ... ''' % datetime.datetime.now(UTC).isoformat())
521
522 We now import this POFile as this language's translation for the soure
523 package:
524diff --git a/lib/lp/translations/doc/rosetta-karma.txt b/lib/lp/translations/doc/rosetta-karma.txt
525index f5bda21..caad946 100644
526--- a/lib/lp/translations/doc/rosetta-karma.txt
527+++ b/lib/lp/translations/doc/rosetta-karma.txt
528@@ -121,7 +121,7 @@ Let's say that we have this .po file to import:
529 >>> import datetime
530 >>> import pytz
531 >>> UTC = pytz.timezone('UTC')
532- >>> pofile_contents = br'''
533+ >>> pofile_contents = six.ensure_binary(r'''
534 ... msgid ""
535 ... msgstr ""
536 ... "Content-Type: text/plain; charset=UTF-8\n"
537@@ -129,7 +129,7 @@ Let's say that we have this .po file to import:
538 ...
539 ... msgid "foo"
540 ... msgstr "bar"
541- ... ''' % datetime.datetime.now(UTC).isoformat()
542+ ... ''' % datetime.datetime.now(UTC).isoformat())
543 >>> potemplate = POTemplate.get(1)
544 >>> pofile = potemplate.getPOFileByLang('es')
545
546@@ -193,7 +193,7 @@ Tell the PO file to import from the file data it has.
547 Now, the user is going to upload a local edition of the .po file. In this
548 case, we will give karma *only* because the translation change.
549
550- >>> pofile_contents = br'''
551+ >>> pofile_contents = six.ensure_binary(r'''
552 ... msgid ""
553 ... msgstr ""
554 ... "Content-Type: text/plain; charset=UTF-8\n"
555@@ -201,7 +201,7 @@ case, we will give karma *only* because the translation change.
556 ...
557 ... msgid "foo"
558 ... msgstr "bars"
559- ... ''' % datetime.datetime.now(UTC).isoformat()
560+ ... ''' % datetime.datetime.now(UTC).isoformat())
561
562 We attach the new file as not comming from upstream.
563
564diff --git a/lib/lp/translations/doc/rosetta-poimport-script.txt b/lib/lp/translations/doc/rosetta-poimport-script.txt
565index 8866db1..680c6a5 100644
566--- a/lib/lp/translations/doc/rosetta-poimport-script.txt
567+++ b/lib/lp/translations/doc/rosetta-poimport-script.txt
568@@ -32,17 +32,17 @@ the sampledata.
569 None
570
571 >>> pofile = potemplate.newPOFile('sr')
572- >>> pofile_content = br'''
573+ >>> pofile_content = six.ensure_binary('''
574 ... msgid ""
575 ... msgstr ""
576- ... "PO-Revision-Date: 2005-06-04 20:41+0100\n"
577- ... "Last-Translator: Danilo Šegan <danilo@canonical.com>\n"
578- ... "Content-Type: text/plain; charset=UTF-8\n"
579- ... "X-Rosetta-Export-Date: %s\n"
580+ ... "PO-Revision-Date: 2005-06-04 20:41+0100\\n"
581+ ... "Last-Translator: Danilo \u0160egan <danilo@canonical.com>\\n"
582+ ... "Content-Type: text/plain; charset=UTF-8\\n"
583+ ... "X-Rosetta-Export-Date: %s\\n"
584 ...
585 ... msgid "Foo %%s"
586 ... msgstr "Bar"
587- ... ''' % datetime.datetime.now(UTC).isoformat()
588+ ... ''' % datetime.datetime.now(UTC).isoformat())
589
590 We clean the import queue.
591
592diff --git a/lib/lp/translations/utilities/tests/test_translation_importer.py b/lib/lp/translations/utilities/tests/test_translation_importer.py
593index 106ca2d..624b84b 100644
594--- a/lib/lp/translations/utilities/tests/test_translation_importer.py
595+++ b/lib/lp/translations/utilities/tests/test_translation_importer.py
596@@ -235,7 +235,7 @@ class TranslationImporterTestCase(TestCaseWithFactory):
597 existing_translation = self.factory.makeCurrentTranslationMessage(
598 pofile=pofile, potmsgset=potmsgset1)
599
600- text = b"""
601+ text = six.ensure_binary("""
602 msgid ""
603 msgstr ""
604 "MIME-Version: 1.0\\n"
605@@ -245,7 +245,7 @@ class TranslationImporterTestCase(TestCaseWithFactory):
606
607 msgid "%s"
608 msgstr "A translation."
609- """ % potmsgset2.msgid_singular.msgid
610+ """ % potmsgset2.msgid_singular.msgid)
611
612 entry = self.factory.makeTranslationImportQueueEntry(
613 'foo.po', potemplate=template, pofile=pofile,

Subscribers

People subscribed via source and target branches

to status/vote changes: