[Python-checkins] r65227 - in python/trunk: Lib/test/test_unicode.py Objects/unicodeobject.c

antoine.pitrou python-checkins at python.org
Fri Jul 25 19:45:59 CEST 2008


Author: antoine.pitrou
Date: Fri Jul 25 19:45:59 2008
New Revision: 65227

Log:
#2242: utf7 decoding crashes on bogus input on some Windows/MSVC versions



Modified:
   python/trunk/Lib/test/test_unicode.py
   python/trunk/Objects/unicodeobject.c

Modified: python/trunk/Lib/test/test_unicode.py
==============================================================================
--- python/trunk/Lib/test/test_unicode.py	(original)
+++ python/trunk/Lib/test/test_unicode.py	Fri Jul 25 19:45:59 2008
@@ -532,6 +532,9 @@
 
         self.assertEqual(unicode('+3ADYAA-', 'utf-7', 'replace'), u'\ufffd')
 
+        # Issue #2242: crash on some Windows/MSVC versions
+        self.assertRaises(UnicodeDecodeError, '+\xc1'.decode, 'utf-7')
+
     def test_codecs_utf8(self):
         self.assertEqual(u''.encode('utf-8'), '')
         self.assertEqual(u'\u20ac'.encode('utf-8'), '\xe2\x82\xac')

Modified: python/trunk/Objects/unicodeobject.c
==============================================================================
--- python/trunk/Objects/unicodeobject.c	(original)
+++ python/trunk/Objects/unicodeobject.c	Fri Jul 25 19:45:59 2008
@@ -1523,7 +1523,7 @@
     while (s < e) {
         Py_UNICODE ch;
         restart:
-        ch = *s;
+        ch = (unsigned char) *s;
 
         if (inShift) {
             if ((ch == '-') || !B64CHAR(ch)) {


More information about the Python-checkins mailing list