Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r59273:612464ae843f
Date: 2012-12-02 15:39 -0800
http://bitbucket.org/pypy/pypy/changeset/612464ae843f/
Log: ensure surrogateescape is fixed, add another encoding related test
and fix
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
@@ -485,6 +485,8 @@
def test_surrogateescape(self):
assert b'a\x80b'.decode('utf-8', 'surrogateescape') == 'a\udc80b'
assert 'a\udc80b'.encode('utf-8', 'surrogateescape') == b'a\x80b'
+ for enc in ('utf-8', 'ascii', 'latin-1', 'charmap'):
+ assert '\udcc3'.encode(enc, 'surrogateescape') == b'\xc3'
def test_surrogatepass_handler(self):
import _codecs
diff --git a/pypy/module/_multibytecodec/test/test_app_codecs.py
b/pypy/module/_multibytecodec/test/test_app_codecs.py
--- a/pypy/module/_multibytecodec/test/test_app_codecs.py
+++ b/pypy/module/_multibytecodec/test/test_app_codecs.py
@@ -63,6 +63,14 @@
raises((IndexError, OverflowError), b"abc\xDD".decode, "hz",
"test.test_decode_custom_error_handler_overflow")
+ def test_decode_custom_error_handler_type(self):
+ import codecs
+ import sys
+ codecs.register_error("test.test_decode_custom_error_handler_type",
+ lambda e: (b'', e.end))
+ raises(TypeError, b"abc\xDD".decode, "hz",
+ "test.test_decode_custom_error_handler_type")
+
def test_encode_hz(self):
import _codecs_cn
codec = _codecs_cn.getcodec("hz")
@@ -107,6 +115,6 @@
import codecs
import sys
codecs.register_error("test.test_encode_custom_error_handler_type",
- lambda e: ('\xc3', e.end))
+ lambda e: (b'\xc3', e.end))
result = "\uDDA1".encode("gbk",
"test.test_encode_custom_error_handler_type")
- assert '\xc3' in result
+ assert b'\xc3' in result
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit