Skip to content

Commit bcc804e

Browse files
author
Vladimir Kotal
authored
handle JSON decode error for older json module versions (#2282)
1 parent 87881ce commit bcc804e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/src/main/python/readconfig.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
import yaml
2727
import sys
2828

29+
# The following is to make the json parsing work on Python 3.4.
30+
try:
31+
from json.decoder import JSONDecodeError
32+
except ImportError:
33+
JSONDecodeError = ValueError
34+
2935

3036
def read_config(logger, inputfile):
3137
"""
@@ -43,7 +49,7 @@ def read_config(logger, inputfile):
4349
try:
4450
logger.debug("trying JSON")
4551
cfg = json.loads(data)
46-
except json.decoder.JSONDecodeError:
52+
except JSONDecodeError:
4753
# Not a valid JSON file.
4854
logger.debug("got exception {}".format(sys.exc_info()[0]))
4955
pass

0 commit comments

Comments
 (0)