← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-translationimportqueue-basestring into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-translationimportqueue-basestring into launchpad:master.

Commit message:
Fix incorrect use of basestring in TranslationImportQueue

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/389438

TranslationImportQueue._getFileObjectAndSize uses file_or_data to construct a BytesIO if it's a basestring, but that doesn't actually make sense: BytesIO only accepts bytes and will raise TypeError if given a unicode object.  Make the isinstance test correct.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-translationimportqueue-basestring into launchpad:master.
diff --git a/lib/lp/translations/model/translationimportqueue.py b/lib/lp/translations/model/translationimportqueue.py
index fa41afa..8856aee 100644
--- a/lib/lp/translations/model/translationimportqueue.py
+++ b/lib/lp/translations/model/translationimportqueue.py
@@ -1056,7 +1056,7 @@ class TranslationImportQueue:
 
     def _getFileObjectAndSize(self, file_or_data):
         """Get the size of a seekable file object."""
-        if (isinstance(file_or_data, basestring)):
+        if isinstance(file_or_data, bytes):
             file_obj = BytesIO(file_or_data)
             file_size = len(file_or_data)
         else: