diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-22 19:41:01 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-22 19:41:01 (GMT) |
commit | 158701d8866b0cb53953bf0ae0fd2834be766da1 (patch) | |
tree | c2acd31b7e74c1d499b7307d4d2a7e4cd6fa7c9a /Lib | |
parent | 754b98c9b4cb355880a464b9e4e9079d96ffc111 (diff) | |
download | cpython-158701d8866b0cb53953bf0ae0fd2834be766da1.zip cpython-158701d8866b0cb53953bf0ae0fd2834be766da1.tar.gz cpython-158701d8866b0cb53953bf0ae0fd2834be766da1.tar.bz2 |
Merged revisions 80382 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r80382 | victor.stinner | 2010-04-22 21:38:16 +0200 (jeu., 22 avril 2010) | 3 lines
Issue #8092: Fix PyUnicode_EncodeUTF8() to support error handler producing
unicode string (eg. backslashreplace)
........
Diffstat (limited to 'Lib')
-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 2c646ba..227e375 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"), |