Commit 160e6821 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

py2/py3: use BytesIO for bytes.

parent 9ccc085b
......@@ -28,7 +28,7 @@
##############################################################################
import re
from six.moves import cStringIO as StringIO
from io import BytesIO
from six.moves import urllib
from cgi import parse_header
import os
......@@ -167,7 +167,7 @@ class ContributionTool(BaseTool):
except KeyError:
raise ValueError('data must be provided')
if data is not None:
file_object = StringIO()
file_object = BytesIO()
file_object.write(data)
file_object.seek(0)
kw['file'] = file_object
......@@ -637,7 +637,7 @@ class ContributionTool(BaseTool):
url_file = urllib.request.urlopen(urllib.request.Request(url,
headers={'Accept':'*/*'}))
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.seek(0)
# 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