diff options
-rw-r--r-- | anyjson/__init__.py | 2 | ||||
-rw-r--r-- | tests/test_implementations.py | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/anyjson/__init__.py b/anyjson/__init__.py index 2238a4c..d0a243c 100644 --- a/anyjson/__init__.py +++ b/anyjson/__init__.py @@ -94,7 +94,7 @@ class _JsonImplementation(object): ValueError if the string could not be parsed.""" # uses StringIO to support buffer objects. try: - if self._filedecode: + if self._filedecode and not isinstance(s, basestring): return self._filedecode(StringIO(s)) return self._decode(s) except self._decode_error, exc: diff --git a/tests/test_implementations.py b/tests/test_implementations.py index a884459..c6f0df2 100644 --- a/tests/test_implementations.py +++ b/tests/test_implementations.py @@ -46,3 +46,12 @@ def test_exceptions(): assert_raises(TypeError, anyjson.serialize, [object()]) assert_raises(ValueError, anyjson.loads, "[") assert_raises(ValueError, anyjson.deserialize, "[") + + +def test_json_loads_unicode(): + try: + anyjson.force_implementation("json") + except ImportError: + return + + assert "foo" in anyjson.loads(u'{"foo": "bar"}') |