Improve exception message for str.format (GH-12675)

This commit is contained in:
Francisco Couzo 2019-06-01 14:14:00 -03:00 committed by Raymond Hettinger
parent cd74e66a8c
commit 9843bc110d
1 changed files with 7 additions and 2 deletions

View File

@ -440,8 +440,13 @@ get_field_object(SubString *input, PyObject *args, PyObject *kwargs,
/* look up in args */
obj = PySequence_GetItem(args, index);
if (obj == NULL)
goto error;
if (obj == NULL) {
PyErr_Format(PyExc_IndexError,
"Replacement index %zd out of range for positional "
"args tuple",
index);
goto error;
}
}
/* iterate over the rest of the field_name */