Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3.5
Changeset: r93414:c9a148ecf262
Date: 2017-12-13 10:05 +0100
http://bitbucket.org/pypy/pypy/changeset/c9a148ecf262/
Log: Applevel test for the utf32 surrogates.
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
@@ -778,6 +778,18 @@
'[]'.encode(encoding))
assert (u'[\udc80]'.encode(encoding, "replace") ==
'[?]'.encode(encoding))
+ for encoding, ill_surrogate in [('utf-8', b'\xed\xb2\x80'),
+ ('utf-16-le', b'\x80\xdc'),
+ ('utf-16-be', b'\xdc\x80'),
+ ('utf-32-le', b'\x80\xdc\x00\x00'),
+ ('utf-32-be', b'\x00\x00\xdc\x80')]:
+ print(encoding)
+ before, after = "[", "]"
+ before_sequence = before.encode(encoding)
+ after_sequence = after.encode(encoding)
+ test_string = before + "\uDC80" + after
+ test_sequence = before_sequence + ill_surrogate + after_sequence
+ raises(UnicodeDecodeError, test_sequence.decode, encoding)
def test_charmap_encode(self):
assert 'xxx'.encode('charmap') == b'xxx'
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit