summaryrefslogtreecommitdiffstats
path: root/Objects/stringlib/string_format.h
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/stringlib/string_format.h')
-rw-r--r--Objects/stringlib/string_format.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/Objects/stringlib/string_format.h b/Objects/stringlib/string_format.h
index 6f10727..6c7adcb 100644
--- a/Objects/stringlib/string_format.h
+++ b/Objects/stringlib/string_format.h
@@ -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)