Use requests exception to handle JSONDecodeError
authorHarmon <Harmon758@gmail.com>
Thu, 6 Jan 2022 00:16:09 +0000 (18:16 -0600)
committerHarmon <Harmon758@gmail.com>
Thu, 6 Jan 2022 00:16:09 +0000 (18:16 -0600)
tweepy/errors.py

index f417d03305abb9402bd71046231ab04239c8cfcf..f760f211069c4a2673d7c7dbaae1eaa21f72efcf 100644 (file)
@@ -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", [])