From: Mike Verdone Date: Wed, 2 Mar 2011 21:18:25 +0000 (+0100) Subject: Explicitly utf8 decode strings coming from Twitter. X-Git-Tag: twitter-1.5.1~4 X-Git-Url: https://jfr.im/git/z_archive/twitter.git/commitdiff_plain/c710b35d50fa729aa0ea42d94000a82e0c6c847f Explicitly utf8 decode strings coming from Twitter. Conflicts: twitter/api.py --- diff --git a/twitter/api.py b/twitter/api.py index 6927f51..3792826 100644 --- a/twitter/api.py +++ b/twitter/api.py @@ -149,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 urllib.HTTPError as e: if (e.code == 304): return [] else: