X-Git-Url: https://jfr.im/git/z_archive/twitter.git/blobdiff_plain/d9269c56c0de08048ac367e445315a993cc7f790..8031bb025fc77ffd0ebb7fa69fe2cf24ffe58844:/twitter/api.py diff --git a/twitter/api.py b/twitter/api.py index 19a5615..6abdd97 100644 --- a/twitter/api.py +++ b/twitter/api.py @@ -1,7 +1,5 @@ import urllib2 -from exceptions import Exception - from twitter.twitter_globals import POST_ACTIONS from twitter.auth import NoAuth @@ -77,7 +75,8 @@ def wrap_response(response, headers): __doc__ = TwitterResponse.__doc__ def __init__(self, response): - response_typ.__init__(self, response) + if response_typ is not int: + response_typ.__init__(self, response) TwitterResponse.__init__(self, headers) return WrappedTwitterResponse(response) @@ -150,11 +149,12 @@ class TwitterCall(object): try: handle = urllib2.urlopen(req) if "json" == self.format: - res = json.loads(handle.read()) + res = json.loads(handle.read().decode('utf8')) return wrap_response(res, handle.headers) else: - return wrap_response(str(handle.read()), handle.headers) - except urllib2.HTTPError, e: + return wrap_response( + handle.read().decode('utf8'), handle.headers) + except urllib2.HTTPError as e: if (e.code == 304): return [] else: