diff options
-rw-r--r-- | Lib/test/test_unicode.py | 3 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index e6b3cb0..604fdf2 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -847,6 +847,9 @@ class UnicodeTest( self.assertEqual(str(b'+3ADYAA-', 'utf-7', 'replace'), '\ufffd') + # Issue #2242: crash on some Windows/MSVC versions + self.assertRaises(UnicodeDecodeError, b'+\xc1'.decode, 'utf-7') + def test_codecs_utf8(self): self.assertEqual(''.encode('utf-8'), b'') self.assertEqual('\u20ac'.encode('utf-8'), b'\xe2\x82\xac') diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index b0b525a..838f537 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1727,7 +1727,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s, while (s < e) { Py_UNICODE ch; restart: - ch = *s; + ch = (unsigned char) *s; if (inShift) { if ((ch == '-') || !B64CHAR(ch)) { |