Merge ~cjwatson/launchpad:py3-bugimporter-bytesio into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: e17ddbf133824d5e231416675d50c5a2cac19603
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-bugimporter-bytesio
Merge into: launchpad:master
Diff against target: 33 lines (+4/-3)
1 file modified
lib/lp/bugs/scripts/bugimport.py (+4/-3)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+396597@code.launchpad.net

Commit message

Port BugImporter to io.BytesIO

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/bugs/scripts/bugimport.py b/lib/lp/bugs/scripts/bugimport.py
2index da403e5..f8c7ea0 100644
3--- a/lib/lp/bugs/scripts/bugimport.py
4+++ b/lib/lp/bugs/scripts/bugimport.py
5@@ -14,8 +14,9 @@ __all__ = [
6 'BugImporter',
7 ]
8
9-from cStringIO import StringIO
10+import base64
11 import datetime
12+import io
13 import logging
14 import os
15 import time
16@@ -394,7 +395,7 @@ class BugImporter:
17 filename = get_value(attachnode, 'filename')
18 title = get_value(attachnode, 'title')
19 mimetype = get_value(attachnode, 'mimetype')
20- contents = get_value(attachnode, 'contents').decode('base-64')
21+ contents = base64.b64decode(get_value(attachnode, 'contents'))
22 if filename is None:
23 # if filename is None, use the last component of the URL
24 if attachnode.get('href') is not None:
25@@ -417,7 +418,7 @@ class BugImporter:
26 filealias = getUtility(ILibraryFileAliasSet).create(
27 name=filename,
28 size=len(contents),
29- file=StringIO(contents),
30+ file=io.BytesIO(contents),
31 contentType=mimetype)
32
33 getUtility(IBugAttachmentSet).create(

Subscribers

People subscribed via source and target branches

to status/vote changes: