Message307955
On Sun, Dec 10, 2017 at 10:00:27AM +0000, Camion wrote:
> Understanding that, I suggest to simply add "(expected 'tuple')" at the end of the message.
> ex : TypeError: 'int' object is not iterable (expected 'tuple')
That is incorrect: a tuple is not expected. Any iterable (sequence,
iterator, tuple, list, set, frozenset, dict, etc) will do. One thing we
should not do is give a misleading, overly-specific message that implies
only a tuple will work.
We could say
TypeError: 'int' object is not iterable (expected iterable)
but that's redundants, since the comment in the parentheses is implied
by the fact that *not* being iterable is an error.
I think the right thing to do here (if possible!) is to distinguish
between unpacking and other iteration. E.g.
for x in 20: ...
=> TypeError: 'int' object is not iterable
a, b = 20
=> TypeError: cannot unpack 'int' object (not iterable)
or similar. I'm less concerned about the exact wording than the fact
that we give a hint that it was the unpacking operation that failed,
rather than iteration in some other context. |
|
Date |
User |
Action |
Args |
2017-12-10 10:31:41 | steven.daprano | set | recipients:
+ steven.daprano, eric.smith, serhiy.storchaka, Camion |
2017-12-10 10:31:41 | steven.daprano | link | issue32259 messages |
2017-12-10 10:31:41 | steven.daprano | create | |
|