Commits

Philip Jenvey  committed 8ba70e2

py3's json operates on unicode/rejects bytes

  • Participants
  • Parent commits 7dc13d6
  • Branches py3k

Comments (0)

Files changed (2)

File pypy/module/_pypyjson/interp_decoder.py

         return 0x10000 + (((highsurr - 0xd800) << 10) | (lowsurr - 0xdc00))
 
 def loads(space, w_s):
-    if space.isinstance_w(w_s, space.w_unicode):
-        raise OperationError(space.w_TypeError,
-                             space.wrap("Expected utf8-encoded str, got unicode"))
+    if space.isinstance_w(w_s, space.w_bytes):
+        raise operationerrfmt(space.w_TypeError,
+                              "Expected string, got %T", w_s)
     s = space.str_w(w_s)
     decoder = JSONDecoder(space, s)
     try:

File pypy/module/_pypyjson/test/test__pypyjson.py

 class AppTest(object):
     spaceconfig = {"objspace.usemodules._pypyjson": True}
 
-    def test_raise_on_unicode(self):
+    def test_raise_on_bytes(self):
         import _pypyjson
-        raises(TypeError, _pypyjson.loads, "42")
+        raises(TypeError, _pypyjson.loads, b"42")
 
 
     def test_decode_constants(self):