launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26051
[Merge] ~cjwatson/launchpad:py3-bugimporter-bytesio into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-bugimporter-bytesio into launchpad:master.
Commit message:
Port BugImporter to io.BytesIO
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/396597
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-bugimporter-bytesio into launchpad:master.
diff --git a/lib/lp/bugs/scripts/bugimport.py b/lib/lp/bugs/scripts/bugimport.py
index da403e5..f8c7ea0 100644
--- a/lib/lp/bugs/scripts/bugimport.py
+++ b/lib/lp/bugs/scripts/bugimport.py
@@ -14,8 +14,9 @@ __all__ = [
'BugImporter',
]
-from cStringIO import StringIO
+import base64
import datetime
+import io
import logging
import os
import time
@@ -394,7 +395,7 @@ class BugImporter:
filename = get_value(attachnode, 'filename')
title = get_value(attachnode, 'title')
mimetype = get_value(attachnode, 'mimetype')
- contents = get_value(attachnode, 'contents').decode('base-64')
+ contents = base64.b64decode(get_value(attachnode, 'contents'))
if filename is None:
# if filename is None, use the last component of the URL
if attachnode.get('href') is not None:
@@ -417,7 +418,7 @@ class BugImporter:
filealias = getUtility(ILibraryFileAliasSet).create(
name=filename,
size=len(contents),
- file=StringIO(contents),
+ file=io.BytesIO(contents),
contentType=mimetype)
getUtility(IBugAttachmentSet).create(