diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-22 19:38:16 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-22 19:38:16 (GMT) |
commit | 31be90b0c7648f3ca802f6624d496511d71e48ef (patch) | |
tree | 2c7589c57e14a804a26dcdf518817168ee6aaa9c /Lib/test/test_codecs.py | |
parent | 29619b2affaf27cfc8c93b97052de7b5eb9fca63 (diff) | |
download | cpython-31be90b0c7648f3ca802f6624d496511d71e48ef.zip cpython-31be90b0c7648f3ca802f6624d496511d71e48ef.tar.gz cpython-31be90b0c7648f3ca802f6624d496511d71e48ef.tar.bz2 |
Issue #8092: Fix PyUnicode_EncodeUTF8() to support error handler producing
unicode string (eg. backslashreplace)
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r-- | Lib/test/test_codecs.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index d2799c3..b17cded 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -571,6 +571,16 @@ class UTF8Test(ReadTest): def test_lone_surrogates(self): self.assertRaises(UnicodeEncodeError, "\ud800".encode, "utf-8") self.assertRaises(UnicodeDecodeError, b"\xed\xa0\x80".decode, "utf-8") + self.assertEqual("[\uDC80]".encode("utf-8", "backslashreplace"), + b'[\\udc80]') + self.assertEqual("[\uDC80]".encode("utf-8", "xmlcharrefreplace"), + b'[�]') + self.assertEqual("[\uDC80]".encode("utf-8", "surrogateescape"), + b'[\x80]') + self.assertEqual("[\uDC80]".encode("utf-8", "ignore"), + b'[]') + self.assertEqual("[\uDC80]".encode("utf-8", "replace"), + b'[?]') def test_surrogatepass_handler(self): self.assertEquals("abc\ud800def".encode("utf-8", "surrogatepass"), |