Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r62337:42ec5de26dd7
Date: 2013-03-14 12:03 -0700
http://bitbucket.org/pypy/pypy/changeset/42ec5de26dd7/
Log: fix surrogatepass
diff --git a/pypy/module/_codecs/interp_codecs.py
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -288,7 +288,7 @@
raise OperationError(space.type(w_exc), w_exc)
res += chr(0xe0 | (ch >> 12))
res += chr(0x80 | ((ch >> 6) & 0x3f))
- res += chr(0x80 | (ch >> 0x3f))
+ res += chr(0x80 | (ch & 0x3f))
return space.newtuple([space.wrapbytes(res), w_end])
elif space.isinstance_w(w_exc, space.w_UnicodeDecodeError):
start = space.int_w(space.getattr(w_exc, space.wrap('start')))
diff --git a/pypy/module/_codecs/test/test_codecs.py
b/pypy/module/_codecs/test/test_codecs.py
--- a/pypy/module/_codecs/test/test_codecs.py
+++ b/pypy/module/_codecs/test/test_codecs.py
@@ -515,6 +515,10 @@
b"abc\xed\xa0\x80def")
assert (b"abc\xed\xa0\x80def".decode("utf-8", "surrogatepass") ==
"abc\ud800def")
+ assert ('surrogate:\udcff'.encode("utf-8", "surrogatepass") ==
+ b'surrogate:\xed\xb3\xbf')
+ assert (b'surrogate:\xed\xb3\xbf'.decode("utf-8", "surrogatepass") ==
+ 'surrogate:\udcff')
raises(UnicodeDecodeError, b"abc\xed\xa0".decode, "utf-8",
"surrogatepass")
raises(UnicodeDecodeError, b"abc\xed\xa0z".decode, "utf-8",
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit