summaryrefslogtreecommitdiff
path: root/simplejson/compat.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-04-25 11:14:29 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2018-04-25 11:14:29 +0300
commit7c7b77d4beae7d2c69947fb1374177ce2095af4e (patch)
treeaae04e92e05c15b19eb33b4b7e0d0774708cb67c /simplejson/compat.py
parent4af3c417547b4a0505e4b1baa5dbd360b7665e7e (diff)
downloadsimplejson-cStringIO.tar.gz
Support builds without cStringIO.cStringIO
The cStringIO module is optional. Fall back to StringIO if it is not available.
Diffstat (limited to 'simplejson/compat.py')
-rw-r--r--simplejson/compat.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/simplejson/compat.py b/simplejson/compat.py
index b5df5af..5fc1412 100644
--- a/simplejson/compat.py
+++ b/simplejson/compat.py
@@ -5,8 +5,11 @@ if sys.version_info[0] < 3:
PY3 = False
def b(s):
return s
- import cStringIO as StringIO
- StringIO = BytesIO = StringIO.StringIO
+ try:
+ from cStringIO import StringIO
+ except ImportError:
+ from StringIO import StringIO
+ BytesIO = StringIO
text_type = unicode
binary_type = str
string_types = (basestring,)
@@ -21,9 +24,7 @@ else:
from imp import reload as reload_module
def b(s):
return bytes(s, 'latin1')
- import io
- StringIO = io.StringIO
- BytesIO = io.BytesIO
+ from io import StringIO, BytesIO
text_type = str
binary_type = bytes
string_types = (str,)