1. Pypy
  2. Untitled project
  3. pypy

Commits

Philip Jenvey  committed 612464a

ensure surrogateescape is fixed, add another encoding related test and fix

  • Participants
  • Parent commits fcd9446
  • Branches py3k

Comments (0)

Files changed (2)

File pypy/module/_codecs/test/test_codecs.py

View file
  • Ignore whitespace
     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

File pypy/module/_multibytecodec/test/test_app_codecs.py

View file
  • Ignore whitespace
         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")
         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