diff options
author | Georg Brandl <georg@python.org> | 2009-09-17 11:28:09 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-09-17 11:28:09 +0000 |
commit | e9741f3ed8487da1d7c8ac8b0c04d3f09802fb1a (patch) | |
tree | 7abc5212bc70ad2f5a217a038681cae4fd71d9d4 /Lib/test/test_codecs.py | |
parent | bc3777d85e9f73bb8e541faf91103fb2374628a3 (diff) | |
download | cpython-git-e9741f3ed8487da1d7c8ac8b0c04d3f09802fb1a.tar.gz |
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/test/test_codecs.py')
-rw-r--r-- | Lib/test/test_codecs.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 06cab1c7ef..18933112a6 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -305,6 +305,12 @@ class UTF32Test(ReadTest): ] ) + def test_handlers(self): + self.assertEqual((u'\ufffd', 1), + codecs.utf_32_decode('\x01', 'replace', True)) + self.assertEqual((u'', 1), + codecs.utf_32_decode('\x01', 'ignore', True)) + def test_errors(self): self.assertRaises(UnicodeDecodeError, codecs.utf_32_decode, "\xff", "strict", True) @@ -422,6 +428,12 @@ class UTF16Test(ReadTest): ] ) + def test_handlers(self): + self.assertEqual((u'\ufffd', 1), + codecs.utf_16_decode('\x01', 'replace', True)) + self.assertEqual((u'', 1), + codecs.utf_16_decode('\x01', 'ignore', True)) + def test_errors(self): self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode, "\xff", "strict", True) |