Closed dhavlik closed 7 years ago
I am merging this because it fixes a bug.
[ale@emily ~]$ python2.7 -c "from json import JSONDecodeError"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name JSONDecodeError
Anyway JSONDecodeError
is present in python3.5
.
[ale@emily ~]$ python3.5 -c "from json import JSONDecodeError"
For this reason a more proper version may be:
try:
import json
except ImportError:
import simplejson as json
try:
JSONDecodeError = json.JSONDecodeError
except AttributeError:
JSONDecodeError = ValueError
There is no JSONDecodeError in python2 stdlib json module, so we created an alias for the ValueError in the try-except importerror-magic.