From 98e213df9c8f6c46ca4dda6093a98bc958086caa Mon Sep 17 00:00:00 2001 From: Mike Helmick Date: Mon, 29 Oct 2012 12:37:16 -0400 Subject: [PATCH] Fixes #121 --- twython/twython.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/twython/twython.py b/twython/twython.py index d8c50b9..9ba5370 100644 --- a/twython/twython.py +++ b/twython/twython.py @@ -165,6 +165,11 @@ class Twython(object): raise TwythonError('Method must be of GET or POST') params = params or {} + # requests doesn't like items that can't be converted to unicode, + # so let's be nice and do that for the user + for k, v in params.items(): + if isinstance(v, (int, bool)): + params[k] = u'%s' % v func = getattr(self.client, method) if method == 'get': @@ -185,15 +190,14 @@ class Twython(object): 'content': content, } - # wrap the json loads in a try, and defer an error # why? twitter will return invalid json with an error code in the headers json_error = False try: content = simplejson.loads(content) except ValueError: - json_error= True - content= {} + json_error = True + content = {} if response.status_code > 304: # If there is no error message, use a default.