Skip to content
Myr

yay json

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

fixes #593

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 7b6338c · Browse files · 1 file+9 added−2 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+9 added−2 removed

  • other:+9 added−2 removed

1 file+9 added−2 removed

modified:requests/models.py+9 added-2 removed
5 unmodified lines
67This module contains the primary objects that power Requests.8"""910import json11import os12from datetime import datetime1314from .hooks import dispatch_hook, HOOKS
781 unmodified lines
796 # Fallback to auto-detected encoding.797 if self.encoding is None:798 if chardet is not None:799 encoding = chardet.detect(self.content)['encoding']799 else:800 raise ValueError("Can't detect page encoding.")800801 # Decode unicode from given encoding.802 try:803 content = str(self.content, encoding, errors='replace')
5 unmodified lines
809 content = str(self.content, errors='replace')810811 return content812813 @property814 def json(self):815 """Returns the json-encoded content of a request, if any."""816 try:817 return json.loads(self.text or self.content)818 except ValueError:819 return None820821 def raise_for_status(self, allow_redirects=True):822 """Raises stored :class:`HTTPError` or :class:`URLError`, if one occurred."""823824 if self.error:
16 unmodified lines