diff options
-rw-r--r-- | simplejson/encoder.py | 4 | ||||
-rw-r--r-- | simplejson/tests/test_str_subclass.py | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/simplejson/encoder.py b/simplejson/encoder.py index 831527b..ae76ae3 100644 --- a/simplejson/encoder.py +++ b/simplejson/encoder.py @@ -52,7 +52,7 @@ def encode_basestring(s, _PY3=PY3, _q=u('"')): else: if isinstance(s, str) and HAS_UTF8.search(s) is not None: s = s.decode('utf-8') - if type(s) not in string_types: + if type(s) not in (str, unicode): if isinstance(s, str): s = str.__str__(s) else: @@ -74,7 +74,7 @@ def py_encode_basestring_ascii(s, _PY3=PY3): else: if isinstance(s, str) and HAS_UTF8.search(s) is not None: s = s.decode('utf-8') - if type(s) not in string_types: + if type(s) not in (str, unicode): if isinstance(s, str): s = str.__str__(s) else: diff --git a/simplejson/tests/test_str_subclass.py b/simplejson/tests/test_str_subclass.py index 771eb67..dc87904 100644 --- a/simplejson/tests/test_str_subclass.py +++ b/simplejson/tests/test_str_subclass.py @@ -14,3 +14,8 @@ class TestStrSubclass(TestCase): self.assertEqual( s, simplejson.loads(simplejson.dumps(WonkyTextSubclass(s)))) + + self.assertEqual( + s, + simplejson.loads(simplejson.dumps(WonkyTextSubclass(s), + ensure_ascii=False))) |