Closes #12579. Positional fields with str.format_map() now raise a ValueError instead of SystemError.

This commit is contained in:
Eric V. Smith 2011-07-18 14:03:41 -04:00
parent b899007268
commit 12ebefc9d3
4 changed files with 20 additions and 0 deletions

View file

@ -511,6 +511,16 @@ get_field_object(SubString *input, PyObject *args, PyObject *kwargs,
Py_DECREF(key);
}
else {
/* If args is NULL, we have a format string with a positional field
with only kwargs to retrieve it from. This can only happen when
used with format_map(), where positional arguments are not
allowed. */
if (args == NULL) {
PyErr_SetString(PyExc_ValueError, "Format string contains "
"positional fields");
goto error;
}
/* look up in args */
obj = PySequence_GetItem(args, index);
if (obj == NULL)