[issue23949] Number of elements display in error message is wrong while unpacking in traceback

Arnon Yaari report at bugs.python.org
Wed Apr 15 17:27:14 CEST 2015


Arnon Yaari added the comment:

I couldn't find a way to add 'got %d' to the 'too many values' message. This would either require going over the rest of the iterator (which will take more time and may never return) or trying to figure out if it has a 'len' member. I didn't find any place in the current code that does something like this and writing one myself is too error prone (there are so many cases...). PyObject_Size returns an error if I try to use it for this purpose.

I found another message with "need more than ..." that I improved in the same way. This message is for when trying to execute:
  >>> a, *(b, c, d) = 1, (2, 3), (4, 5)
Now it outputs the message for the star unpacking:
  ValueError: not enough values to unpack (expected 3, got 2)
which is confusing in this use case but still better than before. Oh my!

----------
Added file: http://bugs.python.org/file39039/issue23949.diff

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


More information about the Python-bugs-list mailing list