summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorFrancisco Couzo <franciscouzo@gmail.com>2019-06-01 17:14:00 (GMT)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2019-06-01 17:14:00 (GMT)
commit9843bc110dc4241ba7cb05f3d3ef74ac6c77caf2 (patch)
treedbee9a61cc76290dd2f719ab698dccbaa744ccab /Objects
parentcd74e66a8c420be675fd2fbf3fe708ac02ee9f21 (diff)
downloadcpython-9843bc110dc4241ba7cb05f3d3ef74ac6c77caf2.zip
cpython-9843bc110dc4241ba7cb05f3d3ef74ac6c77caf2.tar.gz
cpython-9843bc110dc4241ba7cb05f3d3ef74ac6c77caf2.tar.bz2
Improve exception message for str.format (GH-12675)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/stringlib/unicode_format.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/Objects/stringlib/unicode_format.h b/Objects/stringlib/unicode_format.h
index 0fa54eb..ddf1e26 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 */