]> granicus.if.org Git - python/commitdiff
[ Patch #102852 ] Make % error a bit more informative by indicates the
authorAndrew M. Kuchling <amk@amk.ca>
Fri, 15 Dec 2000 13:07:46 +0000 (13:07 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Fri, 15 Dec 2000 13:07:46 +0000 (13:07 +0000)
index at which an unknown %-escape was found

Objects/stringobject.c
Objects/unicodeobject.c

index 8bc97f7fc335fd2cfe10f72c9dff657c4e78a0b7..091ede7ef00fc883413055b9b1c358869c4816c8 100644 (file)
@@ -2939,8 +2939,9 @@ PyString_Format(PyObject *format, PyObject *args)
                                break;
                        default:
                                PyErr_Format(PyExc_ValueError,
-                               "unsupported format character '%c' (0x%x)",
-                                       c, c);
+                                 "unsupported format character '%c' (0x%x) "
+                                 "at index %i",
+                                 c, c, fmt - 1 - PyString_AsString(format));
                                goto error;
                        }
                        if (sign) {
index a297cac4dd20b49a39f83076272f839a71d9228b..5ee72bd128df8d94638c2113debf50d2acac44e5 100644 (file)
@@ -5067,8 +5067,9 @@ PyObject *PyUnicode_Format(PyObject *format,
 
            default:
                PyErr_Format(PyExc_ValueError,
-                            "unsupported format character '%c' (0x%x)",
-                            c, c);
+                            "unsupported format character '%c' (0x%x) "
+                            "at index %i",
+                            c, c, fmt -1 - PyUnicode_AS_UNICODE(uformat));
                goto onError;
            }
            if (sign) {