summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-09-17 11:41:24 (GMT)
committerGeorg Brandl <georg@python.org>2009-09-17 11:41:24 (GMT)
commit791f4e15db62097bca2349635762b08ba2de0bf1 (patch)
treec6567a1a902ad80ab8982401e6b5b101036a189a /Lib
parent7f98a6c0b6bb281343de388b5ad8b1bca2ca39b9 (diff)
downloadcpython-791f4e15db62097bca2349635762b08ba2de0bf1.zip
cpython-791f4e15db62097bca2349635762b08ba2de0bf1.tar.gz
cpython-791f4e15db62097bca2349635762b08ba2de0bf1.tar.bz2
Merged revisions 74869 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk
(Only the new tests, the code had already been corrected due to an API change in unicode_decode_call_errorhandler.) ........ r74869 | georg.brandl | 2009-09-17 13:28:09 +0200 (Do, 17 Sep 2009) | 4 lines Issue #6922: Fix an infinite loop when trying to decode an invalid UTF-32 stream with a non-raising error handler like "replace" or "ignore". ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_codecs.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 9f73453..d0bcf56 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -338,6 +338,12 @@ class UTF32Test(ReadTest):
]
)
+ def test_handlers(self):
+ self.assertEqual(('\ufffd', 1),
+ codecs.utf_32_decode(b'\x01', 'replace', True))
+ self.assertEqual(('', 1),
+ codecs.utf_32_decode(b'\x01', 'ignore', True))
+
def test_errors(self):
self.assertRaises(UnicodeDecodeError, codecs.utf_32_decode,
b"\xff", "strict", True)
@@ -461,6 +467,12 @@ class UTF16Test(ReadTest):
]
)
+ def test_handlers(self):
+ self.assertEqual(('\ufffd', 1),
+ codecs.utf_16_decode(b'\x01', 'replace', True))
+ self.assertEqual(('', 1),
+ codecs.utf_16_decode(b'\x01', 'ignore', True))
+
def test_errors(self):
self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode,
b"\xff", "strict", True)