[issue2242] Decoding UTF-7 with "ignore warnings" crashes Python on Windows Vista

Hirokazu Yamamoto report at bugs.python.org
Fri Jul 25 13:10:21 CEST 2008


Hirokazu Yamamoto <ocean-city at users.sourceforge.net> added the comment:

With this patch? Yes, it fixed crash.

Index: Objects/unicodeobject.c
===================================================================
--- Objects/unicodeobject.c	(revision 65223)
+++ Objects/unicodeobject.c	(working copy)
@@ -1523,7 +1523,7 @@
     while (s < e) {
         Py_UNICODE ch;
         restart:
-        ch = *s;
+        ch = (unsigned char)*s;
 
         if (inShift) {
             if ((ch == '-') || !B64CHAR(ch)) {


>>> '+\xc1'.decode("utf7")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "e:\python-dev\trunk\lib\encodings\utf_7.py", line 12, in decode
    return codecs.utf_7_decode(input, errors, True)
UnicodeDecodeError: 'utf7' codec can't decode bytes in position 0-1:
unexpected

# But I don't know whether this behavior is right or not....

I confirmed test_unicode, test_codecs, test_codeccallbacks passed.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2242>
_______________________________________


More information about the Python-bugs-list mailing list