From 1e627f9fb1cd0bc06704739e4426f6d1218352ac Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 25 Jan 2014 17:15:17 -0500 Subject: [PATCH] need to use ValueError to account for different json libraries throwing different exceptions --- twython/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/twython/api.py b/twython/api.py index c457fd7..db79381 100644 --- a/twython/api.py +++ b/twython/api.py @@ -175,7 +175,7 @@ class Twython(EndpointsMixin, object): try: content = response.json() - except json.JSONDecodeError: + except ValueError: raise TwythonError('Response was not valid JSON. Unable to decode.') return content @@ -188,7 +188,7 @@ class Twython(EndpointsMixin, object): content = response.json() # {"errors":[{"code":34,"message":"Sorry, that page does not exist"}]} error_message = content['errors'][0]['message'] - except json.JSONDecodeError: + except ValueError: # bad json data from Twitter for an error pass except (KeyError, IndexError):