Merge pull request #1900 from mjpieters/issue1674-json-fallback-encoding

Reinstate falling back to self.text for JSON responses
This commit is contained in:
2014-02-11 11:55:20 -05:00
+8 -1
View File
@@ -732,7 +732,14 @@ class Response(object):
# a best guess).
encoding = guess_json_utf(self.content)
if encoding is not None:
return json.loads(self.content.decode(encoding), **kwargs)
try:
return json.loads(self.content.decode(encoding), **kwargs)
except UnicodeDecodeError:
# Wrong UTF codec detected; usually because it's not UTF-8
# but some other 8-bit codec. This is an RFC violation,
# and the server didn't bother to tell us what codec *was*
# used.
pass
return json.loads(self.text, **kwargs)
@property