mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-08 00:47:36 +08:00
bugfix: JSONDecodeError in Python3.4
This commit is contained in:
+10
-3
@@ -8,7 +8,11 @@ This module handles import compatibility issues between Python 2 and
|
|||||||
Python 3.
|
Python 3.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
try:
|
||||||
|
import simplejson as json
|
||||||
|
except ImportError:
|
||||||
|
import json
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# -------
|
# -------
|
||||||
@@ -29,6 +33,11 @@ is_py3 = (_ver[0] == 3)
|
|||||||
# Specifics
|
# Specifics
|
||||||
# ---------
|
# ---------
|
||||||
|
|
||||||
|
try:
|
||||||
|
JSONDecodeError = json.JSONDecodeError
|
||||||
|
except AttributeError:
|
||||||
|
JSONDecodeError = ValueError
|
||||||
|
|
||||||
if is_py2:
|
if is_py2:
|
||||||
from urllib3.packages.ordered_dict import OrderedDict
|
from urllib3.packages.ordered_dict import OrderedDict
|
||||||
|
|
||||||
@@ -40,7 +49,6 @@ if is_py2:
|
|||||||
integer_types = (int, long)
|
integer_types = (int, long)
|
||||||
|
|
||||||
FileNotFoundError = IOError
|
FileNotFoundError = IOError
|
||||||
JSONDecodeError = ValueError
|
|
||||||
|
|
||||||
elif is_py3:
|
elif is_py3:
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
@@ -53,4 +61,3 @@ elif is_py3:
|
|||||||
integer_types = (int,)
|
integer_types = (int,)
|
||||||
|
|
||||||
FileNotFoundError = FileNotFoundError
|
FileNotFoundError = FileNotFoundError
|
||||||
JSONDecodeError = json.decoder.JSONDecodeError
|
|
||||||
|
|||||||
Reference in New Issue
Block a user