diff --git a/src/pygenesis/http_helper.py b/src/pygenesis/http_helper.py index fb17bba..1aa84e6 100644 --- a/src/pygenesis/http_helper.py +++ b/src/pygenesis/http_helper.py @@ -1,4 +1,5 @@ """Wrapper module for the data endpoint.""" +import json import warnings import requests @@ -70,6 +71,7 @@ def _check_invalid_destatis_status_code(response: requests.Response) -> None: # catch possible errors raised by .json() (and only .json()) except ( UnicodeDecodeError, + json.decoder.JSONDecodeError, requests.exceptions.JSONDecodeError, ): response_dict = None diff --git a/tests/unit_tests/test_http_helper.py b/tests/unit_tests/test_http_helper.py index 9607574..cc2e0fa 100644 --- a/tests/unit_tests/test_http_helper.py +++ b/tests/unit_tests/test_http_helper.py @@ -75,7 +75,6 @@ def _generic_request_status( # TODO: Why is specific (UTF-8) encoding necessary? if status_response: - request_status._content = json.dumps(status_dict).encode("utf-8") else: request_status._content = response_text.encode("utf-8")