Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f947ffe

Browse files
committed
Patch #102940: use only printable Unicode chars in reporting
incorrect % characters; characters outside the printable range are replaced with '?'
1 parent 7ff3133 commit f947ffe

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Objects/unicodeobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5069,7 +5069,8 @@ PyObject *PyUnicode_Format(PyObject *format,
50695069
PyErr_Format(PyExc_ValueError,
50705070
"unsupported format character '%c' (0x%x) "
50715071
"at index %i",
5072-
c, c, fmt -1 - PyUnicode_AS_UNICODE(uformat));
5072+
(31<=c && c<=126) ? c : '?',
5073+
c, fmt -1 - PyUnicode_AS_UNICODE(uformat));
50735074
goto onError;
50745075
}
50755076
if (sign) {

0 commit comments

Comments
 (0)