From: Andrew M. Kuchling Date: Fri, 15 Dec 2000 13:07:46 +0000 (+0000) Subject: [ Patch #102852 ] Make % error a bit more informative by indicates the X-Git-Tag: v2.1a1~566 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ca8917758c90bb8de4d3698f9c6ba84167035f5;p=python [ Patch #102852 ] Make % error a bit more informative by indicates the index at which an unknown %-escape was found --- diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 8bc97f7fc3..091ede7ef0 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -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) { diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index a297cac4dd..5ee72bd128 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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) {