Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Reinstate falling back to self.text for JSON responses

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 969195a, f35838b · Browse files · 1 file+8 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−1 removed

  • other:+8 added−1 removed

1 file+8 added−1 removed

modified:requests/models.py+8 added-1 removed
730 unmodified lines
731 # decoding fails, fall back to `self.text` (using chardet to make732 # a best guess).733 encoding = guess_json_utf(self.content)734 if encoding is not None:735 try:735 return json.loads(self.content.decode(encoding), **kwargs)736 return json.loads(self.content.decode(encoding), **kwargs)737 except UnicodeDecodeError:738 # Wrong UTF codec detected; usually because it's not UTF-8739 # but some other 8-bit codec. This is an RFC violation,740 # and the server didn't bother to tell us what codec *was*741 # used.742 pass743 return json.loads(self.text, **kwargs)744745 @property746 def links(self):
37 unmodified lines