[issue21879] str.format() gives poor diagnostic on placeholder mismatch

Roy Smith report at bugs.python.org
Sun Jun 29 16:41:02 CEST 2014


Roy Smith added the comment:

(ugh, hit return too soon)

>>> '{1}'.format()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: tuple index out of range

This is a confusing error message.  The user hasn't written any tuples, so a message about a tuple index out of range will just leave them scratching their head.  We should either return a more specific subclass of IndexError, or at least a more descriptive text describing what went wrong.

See https://mail.python.org/pipermail/python-list/2014-June/674188.html for background.

----------
type:  -> behavior
versions: +Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21879>
_______________________________________


More information about the Python-bugs-list mailing list