openmedialibrary_platform_d.../lib/python3.7/site-packages/simplejson/compat.py

35 lines
815 B
Python
Raw Normal View History

2016-02-06 09:36:57 +00:00
"""Python 3 compatibility shims
"""
import sys
if sys.version_info[0] < 3:
PY3 = False
def b(s):
return s
2018-12-31 23:25:26 +00:00
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
BytesIO = StringIO
2016-02-06 09:36:57 +00:00
text_type = unicode
binary_type = str
string_types = (basestring,)
integer_types = (int, long)
unichr = unichr
reload_module = reload
else:
PY3 = True
if sys.version_info[:2] >= (3, 4):
from importlib import reload as reload_module
else:
from imp import reload as reload_module
def b(s):
2018-12-31 23:25:26 +00:00
return bytes(s, 'latin1')
from io import StringIO, BytesIO
2016-02-06 09:36:57 +00:00
text_type = str
binary_type = bytes
string_types = (str,)
integer_types = (int,)
2018-12-31 23:25:26 +00:00
unichr = chr
2016-02-06 09:36:57 +00:00
long_type = integer_types[-1]