From dd3de986553e9afdad55167046558e8a506f9f8d Mon Sep 17 00:00:00 2001 From: Joy Zheng Date: Thu, 12 Apr 2018 11:52:49 -0700 Subject: [PATCH 1/2] Fix failure to load json in python2 --- plaid/requester.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plaid/requester.py b/plaid/requester.py index a0fbcde94..0377cac51 100644 --- a/plaid/requester.py +++ b/plaid/requester.py @@ -10,6 +10,12 @@ ALLOWED_METHODS = {'post'} DEFAULT_TIMEOUT = 600 # 10 minutes +try: + from json.decoder import JSONDecodeError +except ImportError: + # json parsing throws a ValueError in python3 + JSONDecodeError = ValueError + def _requests_http_request(url, method, data, timeout=DEFAULT_TIMEOUT): normalized_method = method.lower() @@ -32,7 +38,7 @@ def http_request(url, method=None, data=None, timeout=DEFAULT_TIMEOUT): response = _requests_http_request(url, method, data or {}, timeout) try: response_body = json.loads(response.text) - except json.JSONDecodeError: + except JSONDecodeError: raise PlaidError.from_response({ 'error_message': response.text, 'error_type': 'API_ERROR', From 5b0c9d6ec865c1fe20b3039ce74d61fb30e0dfd5 Mon Sep 17 00:00:00 2001 From: Joy Zheng Date: Mon, 16 Apr 2018 09:14:40 -0700 Subject: [PATCH 2/2] fix comment --- plaid/requester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plaid/requester.py b/plaid/requester.py index 0377cac51..ef1b97a8e 100644 --- a/plaid/requester.py +++ b/plaid/requester.py @@ -13,7 +13,7 @@ try: from json.decoder import JSONDecodeError except ImportError: - # json parsing throws a ValueError in python3 + # json parsing throws a ValueError in python2 JSONDecodeError = ValueError