Skip to content

Commit

Permalink
PY3 MimeTypes wants files in text mode.
Browse files Browse the repository at this point in the history
See http://hg.python.org/cpython/file/2766320bdb10/Lib/mimetypes.py#l202

before: 455 failed, 248 passed, 10 skipped, 8 warnings, 55 error in 88.36 seconds
after:  466 failed, 253 passed, 12 skipped, 8 warnings, 49 error in 90.15 seconds
  • Loading branch information
kmike committed Jul 31, 2014
1 parent 7cd271e commit 40cc875
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scrapy/responsetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from mimetypes import MimeTypes
from pkgutil import get_data
from io import BytesIO
from io import StringIO
import six

from scrapy.http import Response
Expand All @@ -33,8 +33,8 @@ class ResponseTypes(object):
def __init__(self):
self.classes = {}
self.mimetypes = MimeTypes()
mimedata = get_data('scrapy', 'mime.types')
self.mimetypes.readfp(BytesIO(mimedata))
mimedata = get_data('scrapy', 'mime.types').decode('utf8')
self.mimetypes.readfp(StringIO(mimedata))
for mimetype, cls in six.iteritems(self.CLASSES):
self.classes[mimetype] = load_object(cls)

Expand Down

0 comments on commit 40cc875

Please sign in to comment.