[pypy-commit] pypy py3k: py3's json operates on unicode/rejects bytes
pjenvey
noreply at buildbot.pypy.org
Sat Jul 20 23:54:52 CEST 2013
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r65519:8ba70e2a8eb9
Date: 2013-07-20 14:47 -0700
http://bitbucket.org/pypy/pypy/changeset/8ba70e2a8eb9/
Log: py3's json operates on unicode/rejects bytes
diff --git a/pypy/module/_pypyjson/interp_decoder.py b/pypy/module/_pypyjson/interp_decoder.py
--- a/pypy/module/_pypyjson/interp_decoder.py
+++ b/pypy/module/_pypyjson/interp_decoder.py
@@ -387,9 +387,9 @@
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:
diff --git a/pypy/module/_pypyjson/test/test__pypyjson.py b/pypy/module/_pypyjson/test/test__pypyjson.py
--- a/pypy/module/_pypyjson/test/test__pypyjson.py
+++ b/pypy/module/_pypyjson/test/test__pypyjson.py
@@ -16,9 +16,9 @@
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):
More information about the pypy-commit
mailing list