Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

On Sun, Dec 10, 2017 at 09:15:16AM +0000, 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 misleading in this context -- the person who raised the 
bug report, and me. It might not be misleading to you, but it mislead 
us. I've been using Python for over a decade and a half, and when I read 
the exception it confused me too: why is the for loop trying to iterate 
over a Fraction? Did the generator accidentally call return instead of 
yield?

I was especially confused because I was expecting a ValueError too 
many/too few values to unpack.

Of course, with a bit more thought I realised that the error isn't 
generated by the for loop, but the unpacking. 15 years of reading 
exceptions does count for something :-)

If you prefer "lacking sufficient information" over misleading, I won't 
disagree. Putting aside pointless quibbles over the exact wording of 
*why* the current error message is suboptimal, I hope that we can all 
agree that if the error occurs during an unpacking operation, the error 
message should preferably say that the object cannot be unpacked. Is 
there any advantage to not giving that information if we can?

> And this is a standard error message raised in many other cases. There 
> is no a bug.

I agreed that it isn't a bug, and changed this to an enhancement. Better 
error messages should be welcomed, not rejected because they aren't 
fixing a bug.

> *Maybe* it can be improved in some specific cases. Do you want to 
> provide a patch Steven? Without concrete patch the following 
> discussion doesn't make sense. We even don't know if such patch is 
> possible.

Someone who knows C and the interpreter internals better than me will 
have to provide a patch. I wouldn't even know where to start looking. 
But my guess would be the UNPACK_SEQUENCE op-code.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32259>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to