Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit f19f64d

Browse files
committed
fix UnicodeDecodeError (bug 941480)
1 parent 70314ab commit f19f64d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mkt/developers/tasks.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ class ResponseTooLargeException(Exception):
231231
def get_content_and_check_size(response, max_size):
232232
# Read one extra byte. Reject if it's too big so we don't have issues
233233
# downloading huge files.
234-
content = response.iter_content(chunk_size=max_size + 1,
235-
decode_unicode=True).next()
234+
content = response.iter_content(chunk_size=max_size + 1).next()
236235
if len(content) > max_size:
237236
raise ResponseTooLargeException('Too much data.')
238237
return content

mkt/developers/tests/test_tasks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ def test_strip_utf8_bom(self):
366366
ur.iter_content.return_value = mock.Mock(next=lambda: content)
367367

368368
tasks.fetch_manifest('url', self.upload.pk)
369+
370+
# Should not be called with anything else (e.g., `decode_unicode`).
371+
ur.iter_content.assert_called_with(
372+
chunk_size=settings.settings.MAX_WEBAPP_UPLOAD_SIZE + 1)
373+
369374
upload = self.get_upload()
370375
with storage.open(upload.path, 'rb') as fp:
371376
manifest = fp.read()

0 commit comments

Comments
 (0)