[issue21911] "IndexError: tuple index out of range" should include the requested index and tuple length

Ram Rachum report at bugs.python.org
Fri Jul 4 00:51:13 CEST 2014


Ram Rachum added the comment:

Mark, again I'm finding myself saying things that are obvious to all of us: You can figure out that "tuple index out of range" means you asked for an item bigger than the size of the tuple, but it might be very helpful for debugging to say the number of item that you asked for and the size of the tuple. For example, maybe it'll say "IndexError: tuple only has 0 elements, can't access element number 1" and you'd be like, "hey, this tuple is empty, it's supposed to have stuff, so the bug is that it's empty", or alternatively it might say "IndexError: tuple only has 10 elements, can't access element number 732426563" and then you'd say "oh, there's a bug in the code that says which number of item I want, this number is very likely wrong for my use case".

Was the above paragraph not quite obvious? Can't we all think of many different examples where you'd want to have that information? Why do I really have to go over these things?

----------

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


More information about the Python-bugs-list mailing list