mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Closes #12579. Positional fields with str.format_map() now raise a ValueError instead of SystemError.
This commit is contained in:
parent
b899007268
commit
12ebefc9d3
4 changed files with 20 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue