From 24540e3b3b845a21ea0e5d7db59d6f30a42fb682 Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 6 Jan 2022 16:56:07 -0800 Subject: [PATCH] Initialize JsonDecodeError before initializing IOError That way we get the formated error message --- requests/exceptions.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requests/exceptions.py b/requests/exceptions.py index 79697635a5..779149ab02 100644 --- a/requests/exceptions.py +++ b/requests/exceptions.py @@ -33,6 +33,9 @@ class InvalidJSONError(RequestException): class JSONDecodeError(InvalidJSONError, CompatJSONDecodeError): """Couldn't decode the text into json""" + def __init__(self, *args, **kwargs): + CompatJSONDecodeError.__init__(self, *args) + InvalidJSONError.__init__(self, *self.args, **kwargs) class HTTPError(RequestException):