[issue21879] str.format() gives poor diagnostic on placeholder mismatch
Terry J. Reedy
report at bugs.python.org
Tue Jul 8 07:15:02 CEST 2014
Terry J. Reedy added the comment:
After reading Eric's comments and checking the signature of .format and rereading the Format String Syntax section, I have changed my mind. The signature of .format is "S.format(*args, **kwargs) -> str" and args is a tuple. So the user asks for creation of a tuple by calling .format. The only unusual part is the the user also provides indexes into the args tuple, but the doc is clear enough that ints passed as specification field names select positional arguments. I think the current message is correct enough to leave alone in current releases. An improved message might be
IndexError("Replacement index %d out of range for positional args tuple")
This uses 'replacement index' as a contraction of 'integer passed as replacement field name'.
----------
type: behavior -> enhancement
versions: -Python 2.7, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21879>
_______________________________________
More information about the Python-bugs-list
mailing list