Commits

Rune Halvorsen committed b7e48d2 Merge

Comments (0)

Files changed (2)

anyjson/__init__.py

         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:

tests/test_implementations.py

         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"}')