diff options
author | Georg Brandl <georg@python.org> | 2009-09-17 11:33:31 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-09-17 11:33:31 (GMT) |
commit | f7a09bec0a57247d32801c94a1a7e7aaf2c9a3ae (patch) | |
tree | 754eff2aaa101b10f947ca015433b32652992557 | |
parent | ecc66d848e4700f51ab645fcff870c3c53dcbabd (diff) | |
download | cpython-f7a09bec0a57247d32801c94a1a7e7aaf2c9a3ae.zip cpython-f7a09bec0a57247d32801c94a1a7e7aaf2c9a3ae.tar.gz cpython-f7a09bec0a57247d32801c94a1a7e7aaf2c9a3ae.tar.bz2 |
Merged revisions 74869 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
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".
........
-rw-r--r-- | Lib/test/test_codecs.py | 12 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 2 |
3 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index cee819c..57420ff 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) @@ -12,6 +12,9 @@ What's New in Python 2.6.3 Core and Builtins ----------------- +- 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". + - Issue #1590864: Fix potential deadlock when mixing threads and fork(). - Issue #6844: Do not emit DeprecationWarnings when accessing a "message" diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index e4f27e6..dbb2b49 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2207,7 +2207,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s, if (unicode_decode_call_errorhandler( errors, &errorHandler, "utf32", errmsg, - starts, size, &startinpos, &endinpos, &exc, &s, + starts, size, &startinpos, &endinpos, &exc, (const char **)&q, &unicode, &outpos, &p)) goto onError; } |