diff options
author | Walter Dörwald <walter@livinglogic.de> | 2003-08-12 17:32:43 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2003-08-12 17:32:43 (GMT) |
commit | fd196bd263c0474c2d40dc2505ce76d4a8f1b9e2 (patch) | |
tree | 7e8d6a8e3250e64fbf336ca5917b94ebe5c36387 /Lib | |
parent | c7a26562f93b8f6fffd65b506ff2aa65297717e4 (diff) | |
download | cpython-fd196bd263c0474c2d40dc2505ce76d4a8f1b9e2.zip cpython-fd196bd263c0474c2d40dc2505ce76d4a8f1b9e2.tar.gz cpython-fd196bd263c0474c2d40dc2505ce76d4a8f1b9e2.tar.bz2 |
Enhance message for UnicodeEncodeError and UnicodeTranslateError.
If there is only one bad character it will now be printed in a
form that is a valid Python string.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_codeccallbacks.py | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index 134d86c..4552462 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -258,7 +258,7 @@ class CodecCallbackTest(unittest.TestCase): self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 2, "ouch"], - "'ascii' codec can't encode character '\ufc' in position 1: ouch" + "'ascii' codec can't encode character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeEncodeError, @@ -268,8 +268,24 @@ class CodecCallbackTest(unittest.TestCase): self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"\xfcx", 0, 1, "ouch"], - "'ascii' codec can't encode character '\ufc' in position 0: ouch" + "'ascii' codec can't encode character '\\xfc' in position 0: ouch" ) + self.check_exceptionobjectargs( + UnicodeEncodeError, + ["ascii", u"\u0100x", 0, 1, "ouch"], + "'ascii' codec can't encode character '\\u0100' in position 0: ouch" + ) + self.check_exceptionobjectargs( + UnicodeEncodeError, + ["ascii", u"\uffffx", 0, 1, "ouch"], + "'ascii' codec can't encode character '\\uffff' in position 0: ouch" + ) + if sys.maxunicode > 0xffff: + self.check_exceptionobjectargs( + UnicodeEncodeError, + ["ascii", u"\U00010000x", 0, 1, "ouch"], + "'ascii' codec can't encode character '\\U00010000' in position 0: ouch" + ) def test_unicodedecodeerror(self): self.check_exceptionobjectargs( @@ -287,10 +303,26 @@ class CodecCallbackTest(unittest.TestCase): self.check_exceptionobjectargs( UnicodeTranslateError, [u"g\xfcrk", 1, 2, "ouch"], - "can't translate character '\\ufc' in position 1: ouch" + "can't translate character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeTranslateError, + [u"g\u0100rk", 1, 2, "ouch"], + "can't translate character '\\u0100' in position 1: ouch" + ) + self.check_exceptionobjectargs( + UnicodeTranslateError, + [u"g\uffffrk", 1, 2, "ouch"], + "can't translate character '\\uffff' in position 1: ouch" + ) + if sys.maxunicode > 0xffff: + self.check_exceptionobjectargs( + UnicodeTranslateError, + [u"g\U00010000rk", 1, 2, "ouch"], + "can't translate character '\\U00010000' in position 1: ouch" + ) + self.check_exceptionobjectargs( + UnicodeTranslateError, [u"g\xfcrk", 1, 3, "ouch"], "can't translate characters in position 1-2: ouch" ) |