bugfix: JSONDecodeError in Python3.4

This commit is contained in:
debugtalk
2018-07-25 23:53:25 +08:00
parent ccad55733f
commit 22a084d301

View File

@@ -8,7 +8,11 @@ This module handles import compatibility issues between Python 2 and
Python 3.
"""
import json
try:
import simplejson as json
except ImportError:
import json
import sys
# -------
@@ -29,6 +33,11 @@ is_py3 = (_ver[0] == 3)
# Specifics
# ---------
try:
JSONDecodeError = json.JSONDecodeError
except AttributeError:
JSONDecodeError = ValueError
if is_py2:
from urllib3.packages.ordered_dict import OrderedDict
@@ -40,7 +49,6 @@ if is_py2:
integer_types = (int, long)
FileNotFoundError = IOError
JSONDecodeError = ValueError
elif is_py3:
from collections import OrderedDict
@@ -53,4 +61,3 @@ elif is_py3:
integer_types = (int,)
FileNotFoundError = FileNotFoundError
JSONDecodeError = json.decoder.JSONDecodeError