From: Francisco Couzo Date: Sat, 1 Jun 2019 17:14:00 +0000 (-0300) Subject: Improve exception message for str.format (GH-12675) X-Git-Tag: v3.8.0b1~73 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9843bc110dc4241ba7cb05f3d3ef74ac6c77caf2;p=python Improve exception message for str.format (GH-12675) --- diff --git a/Objects/stringlib/unicode_format.h b/Objects/stringlib/unicode_format.h index 0fa54eb32c..ddf1e26448 100644 --- a/Objects/stringlib/unicode_format.h +++ b/Objects/stringlib/unicode_format.h @@ -440,8 +440,13 @@ get_field_object(SubString *input, PyObject *args, PyObject *kwargs, /* look up in args */ obj = PySequence_GetItem(args, index); - if (obj == NULL) - goto error; + if (obj == NULL) { + PyErr_Format(PyExc_IndexError, + "Replacement index %zd out of range for positional " + "args tuple", + index); + goto error; + } } /* iterate over the rest of the field_name */