launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26412
[Merge] ~cjwatson/launchpad:py3-tarfile-bytesio into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-tarfile-bytesio into launchpad:master.
Commit message:
Use io.BytesIO when dealing with tarfiles
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398635
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-tarfile-bytesio into launchpad:master.
diff --git a/lib/lp/translations/scripts/tests/test_reupload_translations.py b/lib/lp/translations/scripts/tests/test_reupload_translations.py
index a802b42..c17224f 100644
--- a/lib/lp/translations/scripts/tests/test_reupload_translations.py
+++ b/lib/lp/translations/scripts/tests/test_reupload_translations.py
@@ -7,8 +7,8 @@
__metaclass__ = type
+import io
import re
-from StringIO import StringIO
import tarfile
import six
@@ -60,10 +60,10 @@ def upload_tarball(translation_files):
:param translation_files: A dict mapping filenames to file contents.
:return: A `LibraryFileAlias`.
"""
- buf = StringIO()
+ buf = io.BytesIO()
tarball = tarfile.open('', 'w:gz', buf)
for name, contents in six.iteritems(translation_files):
- pseudofile = StringIO(contents)
+ pseudofile = io.BytesIO(contents)
tarinfo = tarfile.TarInfo()
tarinfo.name = name
tarinfo.size = len(contents)
diff --git a/lib/lp/translations/utilities/tests/test_export_file_storage.py b/lib/lp/translations/utilities/tests/test_export_file_storage.py
index 0cf05df..77d088f 100644
--- a/lib/lp/translations/utilities/tests/test_export_file_storage.py
+++ b/lib/lp/translations/utilities/tests/test_export_file_storage.py
@@ -5,7 +5,7 @@
__metaclass__ = type
-from cStringIO import StringIO
+import io
from tarfile import TarFile
import unittest
@@ -64,7 +64,7 @@ class ExportFileStorageTestCase(unittest.TestCase):
storage.addFile(
'/tmp/another/test.po', 'po', b'another test file', mime)
outfile = storage.export()
- tarball = TarFile.open(mode='r|gz', fileobj=StringIO(outfile.read()))
+ tarball = TarFile.open(mode='r|gz', fileobj=io.BytesIO(outfile.read()))
elements = set(tarball.getnames())
self.assertTrue('/tmp/a/test/file.po' in elements)
self.assertTrue('/tmp/another/test.po' in elements)