Author: Brian Kearns <[email protected]>
Branch: stdlib-2.7.6
Changeset: r69608:6f8dc12b87a0
Date: 2014-03-02 05:12 -0500
http://bitbucket.org/pypy/pypy/changeset/6f8dc12b87a0/
Log: add codeccallback test that passes after last 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
@@ -589,6 +589,16 @@
else:
assert res == u"\x00\x00\x01\x00\x00" # UCS2 build
+ def handler1(exc):
+ if not isinstance(exc, UnicodeEncodeError) \
+ and not isinstance(exc, UnicodeDecodeError):
+ raise TypeError("don't know how to handle %r" % exc)
+ l = [u"<%d>" % ord(exc.object[pos]) for pos in xrange(exc.start,
exc.end)]
+ return (u"[%s]" % u"".join(l), exc.end)
+ codecs.register_error("test.handler1", handler1)
+ assert "\\u3042\u3xxx".decode("unicode-escape", "test.handler1") == \
+ u"\u3042[<92><117><51>]xxx"
+
def test_encode_error_bad_handler(self):
import codecs
codecs.register_error("test.bad_handler", lambda e: (repl, 1))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit