[Python-checkins] r74872 - in python/branches/release31-maint: Lib/test/test_codecs.py

georg.brandl python-checkins at python.org
Thu Sep 17 13:46:23 CEST 2009


Author: georg.brandl
Date: Thu Sep 17 13:46:23 2009
New Revision: 74872

Log:
Merged revisions 74871 via svnmerge from 
svn+ssh://svn.python.org/python/branches/py3k

................
  r74871 | georg.brandl | 2009-09-17 13:41:24 +0200 (Do, 17 Sep 2009) | 12 lines
  
  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".
  ........
................


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Lib/test/test_codecs.py

Modified: python/branches/release31-maint/Lib/test/test_codecs.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_codecs.py	(original)
+++ python/branches/release31-maint/Lib/test/test_codecs.py	Thu Sep 17 13:46:23 2009
@@ -338,6 +338,12 @@
             ]
         )
 
+    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 @@
             ]
         )
 
+    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)


More information about the Python-checkins mailing list