group exceptions to 2 types: failure and error

This commit is contained in:
debugtalk
2018-07-25 10:40:20 +08:00
parent 7a2920fac2
commit 7478331cb5
12 changed files with 60 additions and 54 deletions

View File

@@ -8,6 +8,7 @@ This module handles import compatibility issues between Python 2 and
Python 3.
"""
import json
import sys
# -------
@@ -23,10 +24,6 @@ is_py2 = (_ver[0] == 2)
#: Python 3.x?
is_py3 = (_ver[0] == 3)
try:
import simplejson as json
except ImportError:
import json
# ---------
# Specifics
@@ -42,6 +39,9 @@ if is_py2:
numeric_types = (int, long, float)
integer_types = (int, long)
FileNotFoundError = IOError
JSONDecodeError = json.decoder.JSONDecodeError
elif is_py3:
from collections import OrderedDict
@@ -51,3 +51,6 @@ elif is_py3:
basestring = (str, bytes)
numeric_types = (int, float)
integer_types = (int,)
FileNotFoundError = FileNotFoundError
JSONDecodeError = ValueError