summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorEric V. Smith <eric@trueblade.com>2011-07-18 18:03:41 (GMT)
committerEric V. Smith <eric@trueblade.com>2011-07-18 18:03:41 (GMT)
commit12ebefc9d3b7268d17d4a042767f712c46d03dfe (patch)
treea9e5fce407f2f3c5006e2278d1c18868c9b80bcb /Objects
parentb899007268c53f2f169562bd0679fd5d688e185c (diff)
downloadcpython-12ebefc9d3b7268d17d4a042767f712c46d03dfe.zip
cpython-12ebefc9d3b7268d17d4a042767f712c46d03dfe.tar.gz
cpython-12ebefc9d3b7268d17d4a042767f712c46d03dfe.tar.bz2
Closes #12579. Positional fields with str.format_map() now raise a ValueError instead of SystemError.
Diffstat (limited to 'Objects')
-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)