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

2017-12-26 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

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

2017-12-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 13a6c098c215921e35004f9d3a9b70f601e56500 by Serhiy Storchaka in branch 'master': bpo-32259: Make a TypeError message when unpack non-iterable more specific. (#4903)

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

2017-12-19 Thread Camion
Camion added the comment: Ok then. Thank you :-) It also seemed strange that there were so many messages about int ;-) -- ___ Python tracker

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

2017-12-19 Thread Terry J. Reedy
Terry J. Reedy added the comment: Yes, in the code for the the unpack message test, the specific non-iterable is not relevant. These are not tests of the iter builtin. -- ___ Python tracker

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

2017-12-19 Thread Camion
Camion added the comment: Even in the code !?? I may have missed something, but I based my question on what I read in the pull request... -- ___ Python tracker

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

2017-12-18 Thread Terry J. Reedy
Terry J. Reedy added the comment: 'int' is a standin for non-iterable and easy to type. -- ___ Python tracker ___

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

2017-12-18 Thread Camion
Camion added the comment: thank You Serhiy for your C implementation. About this question of the dilemma around the meaning of "non iterable int" why not simply put the "non iterable" between parenthesis to avoid making it too verbose ? "cannot unpack

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

2017-12-18 Thread Terry J. Reedy
Terry J. Reedy added the comment: I retested and iter(ob) (1) apparently raises 'not iterable' only when it can find neither __iter__ nor __getitem__. It (2) raises 'non-iterator', as above, when it finds __iter__, calls its, and get a non-iterator. (3) Exceptions in

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

2017-12-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Is it worth to emit more specific (but possible uniform) error messages in other unpacking cases (see msg307999)? FYI if a class implements __iter__ which returns non-iterable, the following error is raised: >>> class C: ...

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

2017-12-18 Thread Terry J. Reedy
Terry J. Reedy added the comment: In English, 'adjective noun' does not necessarily imply the existence of 'not-adjective' nouns, and the adjective may serve as a reminder or reason. For instance, "This job is too dangerous for mortal humans!" In the current context,

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

2017-12-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > I would add 'non-iterable', to get "cannot unpack non-iterable int object", > to tell people what is needed instead. Doesn't this imply that there are iterable int objects which can be unpacked? --

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

2017-12-17 Thread Terry J. Reedy
Terry J. Reedy added the comment: Thanks, Serhiy, for the C implementation, and Eric for reviewing it. I would add 'non-iterable', to get "cannot unpack non-iterable int object", to tell people what is needed instead. I do think this worthwhile. --

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

2017-12-17 Thread Eric V. Smith
Eric V. Smith added the comment: The PR looks okay to me. I'm also not sure it's worth the change, though. -- ___ Python tracker

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

2017-12-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: PR 4903 makes the error message more specific for this case. >>> a, b = 1 Traceback (most recent call last): File "", line 1, in TypeError: cannot unpack int object I don't know whether it is worth to do this change.

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

2017-12-16 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +4798 stage: needs patch -> patch review ___ Python tracker ___

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

2017-12-16 Thread Camion
Camion added the comment: Jerry, I've been troubleshooting thing for 30 years and I'm quite experienced at it, and in the end I was perfectly able to manage this problem and solve this problem by myself. My point is not about my own difficulty to solve this

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

2017-12-15 Thread Terry J. Reedy
Terry J. Reedy added the comment: I think generically changing 'iterable' to 'iterable/unpackable' is wrong and would engender more confusion than at present. Most uses of iteration have nothing to do with multiple assignment target unpacking. Some minimal examples

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

2017-12-10 Thread Camion
Camion added the comment: Woops, my mistake... I fumbled this one : the file was empty -- keywords: +patch Added file: https://bugs.python.org/file47330/issue-32259-iterable-unpackable.patch ___ Python tracker

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

2017-12-10 Thread Camion
Camion added the comment: Well I submitted a patch, but I don't see it anywhere on this page.. Is this normal ? -- ___ Python tracker

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

2017-12-10 Thread Camion
Camion added the comment: @Raymond: I know that you have no obligation to make changes just because I'm demanding them and that's why I'm just trying to convince people of the validity of my observations, here. I apologize if my tone may seem "insistent", but

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

2017-12-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Camion, the problem is not in the error message. The problem is in the complex expression that produces an error. If you have a complex expression you always have a change to misidentify the source of error. In your case the

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

2017-12-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: @Camion, please adopt a less insistent tone. We've devoting time and thought to your concerns but are under no obligation to make a change just because you are demanding it. Part of learning any programming language is

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

2017-12-10 Thread R. David Murray
R. David Murray added the comment: I shouldn't have searched the docs for 'unpackable', I should have searched for 'unpack'. Doing that reveals that the term 'unpack' is used for other concepts, whereas the term 'iterable' is precise. So I think it would unacceptably

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

2017-12-10 Thread R. David Murray
R. David Murray added the comment: > How about "[TYPE] object is not iterable/unpackable" I just grepped the docs, and the term 'unpackable' does not appear anywhere in them. I don't think this would be an improvement. As for the earlier suggestion of adding "expected

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

2017-12-10 Thread Camion
Camion added the comment: @Serhiy : I asked you to explain by what mean you supported the affirmation that our feeling (that the current message can be misleading in the specific situation) is wrong, but you didn't give us any element to understand your

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

2017-12-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: My objections were about the original report. The title of this issue still implies there is a bug that is not true. You proposition Steve may make sense, but we need a concrete code for discussing the advantages and the

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

2017-12-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: I think the current error message should stay as is. The interpreter is in no position to guess what kind of iterable may have been intended. -- nosy: +rhettinger ___ Python tracker

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

2017-12-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sun, Dec 10, 2017 at 10:00:27AM +, 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

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

2017-12-10 Thread Steven D'Aprano
Steven D'Aprano added the comment: On Sun, Dec 10, 2017 at 09:15:16AM +, Serhiy Storchaka wrote: > My point is that the current error message is correct and is not misleading. With respect Serhiy, in this bug report you have TWO PEOPLE who have said that it is

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

2017-12-10 Thread Camion
Camion 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 "", line 1, in a, b = 1, ValueError: need more

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

2017-12-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: My point is that the current error message is correct and is not misleading. And this is a standard error message raised in many other cases. There is no a bug. *Maybe* it can be improved in some specific cases. Do you want to

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

2017-12-09 Thread Camion
Camion added the comment: By the way, I guess if the problem arises like that, it's because it might be hard to distinguish both situations at the interpreter level, but if it was possible, it would be the best solution to have a different error message (even if

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

2017-12-09 Thread Camion
Camion added the comment: I wrote it like that on purpose, Steven : My goal was not to show the message itself which (I believe) was sufficiently described in the explanation, but to show how hard it might be to understand the mistake in regard with the error

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

2017-12-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: I agree with Camion that the error message is misleading, and not just for beginners. It threw me for a loop too, when I first read it. Serhiy is right, the exception type cannot and should not be changed, but we can change the

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

2017-12-09 Thread Camion
Camion added the comment: I'm not talking about changing the type of the exception, Serhiy. but only to make the text message more explicit by adding a lead to a secondary possible cause. I do not understand how this addition would be misleading - more than the

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

2017-12-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I concur with Eric. The current exception is correct and allows to identify your mistake. Changing the type of the exception will break an existing code, and the message proposed by you is misleading. -- nosy:

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

2017-12-09 Thread Camion
Camion added the comment: Ok, but the other explanation is valid as well. That's why I suggest to modify the error message like this : TypeError: '[TYPE]' object is not iterable - OR - ValueError: not enough values to unpack (expected [N], got 1) --

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

2017-12-09 Thread Eric V. Smith
Eric V. Smith added the comment: The error message is correct, but I'm sorry it's confusing. Here's an equivalent error: a, b = 3 You'll get the error "TypeError: 'int' object is not iterable". That's because Python sees 2 items to the left of the assignment, so it needs

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

2017-12-09 Thread Camion
New submission from Camion : I'm new with Python and I've been blocked for day on a "TypeError: 'Fraction' object is not iterable" error message, while the problem turned out to be completely different. I don't even know to what programming case this message