From b492b0a9fd4a0fedbc03cc2cc1927c45e866cb4e Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 5 Jan 2022 18:16:09 -0600 Subject: [PATCH] Use requests exception to handle JSONDecodeError --- tweepy/errors.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tweepy/errors.py b/tweepy/errors.py index f417d03..f760f21 100644 --- a/tweepy/errors.py +++ b/tweepy/errors.py @@ -2,12 +2,7 @@ # Copyright 2009-2022 Joshua Roesslein # See LICENSE for details. -try: - # Handle https://github.com/psf/requests/issues/5794 until requests 2.27.0 - # is released with https://github.com/psf/requests/pull/5856 - import simplejson as json -except ImportError: - import json +import requests class TweepyException(Exception): @@ -46,7 +41,7 @@ class HTTPException(TweepyException): try: response_json = response.json() - except json.JSONDecodeError: + except requests.JSONDecodeError: super().__init__(f"{response.status_code} {response.reason}") else: errors = response_json.get("errors", []) -- 2.25.1