Ask Solem  committed c828bf8

Seems like json can't load StringIO to a unicode string

  • Participants
  • Parent commits 0716ddb
  • Branches default

Comments (0)

Files changed (2)

File anyjson/

         ValueError if the string could not be parsed."""
         # uses StringIO to support buffer objects.
-            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:

File tests/

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