Update twython.py

if unicode object is detected, convert it to json using simplejson/json
This commit is contained in:
Virendra Rajput 2013-04-08 22:59:27 +05:30
parent 4a181d3ac1
commit 6a3539882c

View file

@ -186,7 +186,12 @@ class Twython(object):
# why? twitter will return invalid json with an error code in the headers # why? twitter will return invalid json with an error code in the headers
json_error = False json_error = False
try: try:
content = content.json() try:
# try to get json
content = content.json()
except AttributeError:
# if unicode detected
content = json.loads(content)
except ValueError: except ValueError:
json_error = True json_error = True
content = {} content = {}