From 0fc1e450548ff8bfb6fc4eb4a987ec9b4412b962 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Mon, 18 Apr 2011 16:13:59 -0300 Subject: [PATCH] Use ValueError instad of JSONDecodeError to support django.utils.simplejson utility properly on systems where python-simplejson is not present --- social_auth/backends/__init__.py | 2 +- social_auth/backends/contrib/orkut.py | 2 +- social_auth/backends/facebook.py | 2 +- social_auth/backends/google.py | 2 +- social_auth/backends/twitter.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/social_auth/backends/__init__.py b/social_auth/backends/__init__.py index 5325660..a415887 100644 --- a/social_auth/backends/__init__.py +++ b/social_auth/backends/__init__.py @@ -660,7 +660,7 @@ class BaseOAuth2(BaseOAuth): try: response = simplejson.loads(urlopen(request).read()) - except (simplejson.JSONDecodeError, KeyError): + except (ValueError, KeyError): raise ValueError('Unknown OAuth2 response type') if response.get('error'): diff --git a/social_auth/backends/contrib/orkut.py b/social_auth/backends/contrib/orkut.py index 4ffbf60..ebd3021 100644 --- a/social_auth/backends/contrib/orkut.py +++ b/social_auth/backends/contrib/orkut.py @@ -62,7 +62,7 @@ class OrkutAuth(BaseGoogleOAuth): response = urllib.urlopen(request.to_url()).read() try: return simplejson.loads(response)['data'] - except (simplejson.JSONDecodeError, KeyError): + except (ValueError, KeyError): return None diff --git a/social_auth/backends/facebook.py b/social_auth/backends/facebook.py index 2c14145..26f541e 100644 --- a/social_auth/backends/facebook.py +++ b/social_auth/backends/facebook.py @@ -88,7 +88,7 @@ class FacebookAuth(BaseOAuth): url = FACEBOOK_CHECK_AUTH + '?' + urllib.urlencode(params) try: return simplejson.load(urllib.urlopen(url)) - except simplejson.JSONDecodeError: + except ValueError: return None @classmethod diff --git a/social_auth/backends/google.py b/social_auth/backends/google.py index 9210f54..efc4a3d 100644 --- a/social_auth/backends/google.py +++ b/social_auth/backends/google.py @@ -167,7 +167,7 @@ def googleapis_email(url, params): request = Request(url + '?' + params, headers={'Authorization': params}) try: return simplejson.loads(urlopen(request).read())['data'] - except (simplejson.JSONDecodeError, KeyError, IOError): + except (ValueError, KeyError, IOError): return None diff --git a/social_auth/backends/twitter.py b/social_auth/backends/twitter.py index aaed2c9..8f87cf8 100644 --- a/social_auth/backends/twitter.py +++ b/social_auth/backends/twitter.py @@ -56,7 +56,7 @@ class TwitterAuth(ConsumerBasedOAuth): json = self.fetch_response(request) try: return simplejson.loads(json) - except simplejson.JSONDecodeError: + except ValueError: return None -- 2.39.5