python: Catch JSONDecodeError instead of ValueError when decoding JSON.

These weren’t wrong since orjson.JSONDecodeError subclasses
json.JSONDecodeError which subclasses ValueError, but the more
specific ones express the intention more clearly.

(ujson raised ValueError directly, as did json in Python 2.)

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-08-12 11:23:23 -07:00
committed by Tim Abbott
parent 2e97d2b9f7
commit d0f4af5f8c
10 changed files with 11 additions and 11 deletions

View File

@@ -272,7 +272,7 @@ def process_success_response(event: Dict[str, Any],
response: Response) -> None:
try:
response_json = json.loads(response.text)
except ValueError:
except json.JSONDecodeError:
fail_with_message(event, "Invalid JSON in response")
return