projects
/
services
/
python-requests.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8b141b3
)
keep json None fo row
author
Kenneth Reitz
<me@kennethreitz.com>
Mon, 17 Dec 2012 03:06:03 +0000
(22:06 -0500)
committer
Kenneth Reitz
<me@kennethreitz.com>
Mon, 17 Dec 2012 03:06:03 +0000
(22:06 -0500)
requests/models.py
patch
|
blob
|
history
diff --git
a/requests/models.py
b/requests/models.py
index
9972944
..
342d3e4
100644
(file)
--- a/
requests/models.py
+++ b/
requests/models.py
@@
-1048,10
+1048,14
@@
class Response(BaseResponse):
# a best guess).
encoding = guess_json_utf(self.content)
if encoding is not None:
- return json.loads(self.content.decode(encoding))
-
- return json.loads(self.text or self.content)
-
+ try:
+ return json.loads(self.content.decode(encoding))
+ except (ValueError, UnicodeDecodeError):
+ pass
+ try:
+ return json.loads(self.text or self.content)
+ except ValueError:
+ return None
@property
def links(self):