PyUnicode_FromFormatV broken when using a width
This code should work but segfaults on PyPy
PyErr_Format(PyExc_TypeError, "formatting 100R '%.100R'", obj);
The problem is the formatting string. It trips up the code in PyUnicode_FromFormatV
, which expects %R100
instead:
for (f = format; *f; f++) {
if (*f == '%') {
if (*(f+1)=='%')
continue;
if (*(f+1)=='S' || *(f+1)=='R' || *(f+1)=='A' || *(f+1) == 'V')
++callcount;
while (Py_ISDIGIT((unsigned)*f))
width = (width*10) + *f++ - '0';
while (*++f && *f != '%' && !Py_ISALPHA((unsigned)*f))
;
if (*f == 's')
++callcount;
}
...
See the failing test in the format-width branch