Commit 6ca89177 authored by Andrew M. Kuchling's avatar Andrew M. Kuchling

[ Patch #102852 ] Make % error a bit more informative by indicates the

index at which an unknown %-escape was found
parent 29c45a5e
...@@ -2939,8 +2939,9 @@ PyString_Format(PyObject *format, PyObject *args) ...@@ -2939,8 +2939,9 @@ PyString_Format(PyObject *format, PyObject *args)
break; break;
default: default:
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"unsupported format character '%c' (0x%x)", "unsupported format character '%c' (0x%x) "
c, c); "at index %i",
c, c, fmt - 1 - PyString_AsString(format));
goto error; goto error;
} }
if (sign) { if (sign) {
......
...@@ -5067,8 +5067,9 @@ PyObject *PyUnicode_Format(PyObject *format, ...@@ -5067,8 +5067,9 @@ PyObject *PyUnicode_Format(PyObject *format,
default: default:
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"unsupported format character '%c' (0x%x)", "unsupported format character '%c' (0x%x) "
c, c); "at index %i",
c, c, fmt -1 - PyUnicode_AS_UNICODE(uformat));
goto onError; goto onError;
} }
if (sign) { if (sign) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment