Mercurial > cpython-lru_cache-weakref
diff Objects/stringlib/string_format.h @ 71409:f6d074a7bbd4 3.2
Closes #12579. Positional fields with str.format_map() now raise a ValueError instead of SystemError.
| author | Eric V. Smith <eric@trueblade.com> |
|---|---|
| date | Mon, 18 Jul 2011 14:03:41 -0400 |
| parents | 81d7f78a633a |
| children | 3fb9464f9b02 102df748572d |
line wrap: on
line diff
--- a/Objects/stringlib/string_format.h Mon Jul 18 12:38:03 2011 -0400 +++ b/Objects/stringlib/string_format.h Mon Jul 18 14:03:41 2011 -0400 @@ -511,6 +511,16 @@ 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)
