diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 43d8c5d39ee..53c7800c9a3 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -392,6 +392,7 @@ class UnicodeTest( self.assertEqual(u'%c' % 0x1234, u'\u1234') self.assertRaises(OverflowError, u"%c".__mod__, (sys.maxunicode+1,)) + self.assertRaises(ValueError, u"%.1\u1032f".__mod__, (1.0/3)) for num in range(0x00,0x80): char = chr(num) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index d05685514de..571f607c3c1 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8607,7 +8607,7 @@ PyObject *PyUnicode_Format(PyObject *format, else if (c >= '0' && c <= '9') { prec = c - '0'; while (--fmtcnt >= 0) { - c = Py_CHARMASK(*fmt++); + c = *fmt++; if (c < '0' || c > '9') break; if ((prec*10) / 10 != prec) {