[issue32259] Misleading "not iterable" Error Message when generator return a "simple" type, and a tuple is expected

Camion report at bugs.python.org
Sun Dec 10 05:00:27 EST 2017


Camion <camion_spam-pybugs at yahoo.com> added the comment:

Serhiy, I think I got a better understanding of what is happening. It is well described by the following example :

>>> a, b = 1,

Traceback (most recent call last):
  File "<pyshell#40>", line 1, in <module>
    a, b = 1,
ValueError: need more than 1 value to unpack
>>> a, b = 1

Traceback (most recent call last):
  File "<pyshell#41>", line 1, in <module>
    a, b = 1
TypeError: 'int' object is not iterable

Again, the message might be correct, but in this case, the combination between the message and the ambiguous syntax, makes it lack from explicitness.

Understanding that, I suggest to simply add "(expected 'tuple')" at the end of the message.
ex : TypeError: 'int' object is not iterable (expected 'tuple')

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32259>
_______________________________________


More information about the Python-bugs-list mailing list