Commit 6ad2d5fd authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Arnaud Fontaine

py2/py3: use BytesIO for bytes.

parent 66eb6bd4
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
############################################################################## ##############################################################################
import re import re
from six.moves import cStringIO as StringIO from io import BytesIO
from six.moves import urllib from six.moves import urllib
from cgi import parse_header from cgi import parse_header
import os import os
...@@ -167,7 +167,7 @@ class ContributionTool(BaseTool): ...@@ -167,7 +167,7 @@ class ContributionTool(BaseTool):
except KeyError: except KeyError:
raise ValueError('data must be provided') raise ValueError('data must be provided')
if data is not None: if data is not None:
file_object = StringIO() file_object = BytesIO()
file_object.write(data) file_object.write(data)
file_object.seek(0) file_object.seek(0)
kw['file'] = file_object kw['file'] = file_object
...@@ -637,7 +637,7 @@ class ContributionTool(BaseTool): ...@@ -637,7 +637,7 @@ class ContributionTool(BaseTool):
url_file = urllib.request.urlopen(urllib.request.Request(url, url_file = urllib.request.urlopen(urllib.request.Request(url,
headers={'Accept':'*/*'})) headers={'Accept':'*/*'}))
data = url_file.read() # time out must be set or ... too long XXX data = url_file.read() # time out must be set or ... too long XXX
file_object = StringIO() file_object = BytesIO()
file_object.write(data) file_object.write(data)
file_object.seek(0) file_object.seek(0)
# if a content-disposition header is present, # if a content-disposition header is present,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment