summaryrefslogtreecommitdiff
path: root/simplejson
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2018-04-25 09:42:03 -0700
committerGitHub <noreply@github.com>2018-04-25 09:42:03 -0700
commitf35e2e2d6aca34c4b9ce2e3d61568fc6d09a6b9d (patch)
tree6c9c56e504ebbfe68916798fb1ee2daebf631601 /simplejson
parent831764b485060d11f903e050904d53ac42337d16 (diff)
parent7a2c88f768084a41eabb137d6e82f4ed2be0ce54 (diff)
downloadsimplejson-f35e2e2d6aca34c4b9ce2e3d61568fc6d09a6b9d.tar.gz
Merge branch 'master' into str-decodestr-decode
Diffstat (limited to 'simplejson')
-rw-r--r--simplejson/compat.py11
-rw-r--r--simplejson/tests/__init__.py8
2 files changed, 13 insertions, 6 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,)
diff --git a/simplejson/tests/__init__.py b/simplejson/tests/__init__.py
index 8d2642f..25d3305 100644
--- a/simplejson/tests/__init__.py
+++ b/simplejson/tests/__init__.py
@@ -1,6 +1,5 @@
from __future__ import absolute_import
import unittest
-import doctest
import sys
import os
@@ -28,6 +27,13 @@ def additional_tests(suite=None):
import simplejson.decoder
if suite is None:
suite = unittest.TestSuite()
+ try:
+ import doctest
+ except ImportError:
+ if sys.version_info < (2, 7):
+ # doctests in 2.6 depends on cStringIO
+ return suite
+ raise
for mod in (simplejson, simplejson.encoder, simplejson.decoder):
suite.addTest(doctest.DocTestSuite(mod))
suite.addTest(doctest.DocFileSuite('../../index.rst'))