From 79dd08d50931cdcab52fa5788bb390183b7424e3 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 16 Dec 2019 12:02:19 +0000 Subject: [PATCH] Compatible json with python < 3.5 As you can see in https://docs.python.org/3/library/json.html#json.JSONDecodeError this exception was added in Python 3.5. Having to require `simplejson` just for the exception seems a bit too much for the job. It's easier to handle that `ImportError` separately and still allow the native `json` module to work. --- client/wdb/_compat.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/wdb/_compat.py b/client/wdb/_compat.py index 5f0879ec..284bae0d 100644 --- a/client/wdb/_compat.py +++ b/client/wdb/_compat.py @@ -5,7 +5,11 @@ python_version = sys.version_info[0] try: - from json import loads, dumps, JSONEncoder, JSONDecodeError + from json import loads, dumps, JSONEncoder + try: + from json import JSONDecodeError + except ImportError: + JSONDecodeError = ValueError # python < 3.5 except ImportError: from simplejson import loads, dumps, JSONEncoder, JSONDecodeError