[Python-ideas] PEP 479: Change StopIteration handling inside generators

Guido van Rossum guido at python.org
Tue Nov 18 05:50:14 CET 2014


Nick,

I think we've gone through enough clarifications of the PEP now to be clear
on the proposal. I saw in one of your earliest replies (right after Chris
posted his first draft) that you're hesitant to support the PEP because of
what would have to change to contextlib. What I couldn't quite read is
whether you think that the proposal by itself is not an improvement, or
whether you're just worried about compatibility.

Apparently you know of a large group of users who use an older 3rd party
version of contextlib, and for whom that older, 3rd party contextlib should
keep working with future versions of Python 3 without updating their
version of contextlib -- did I get that right? What exactly is the
constraint there that makes their version of contextlib immutable even
though the version of Python they are using may move forward?

Separate from this special case, I am also worried about backward
compatibility, and I have yet to get a good idea for how widespread code is
that depends on StopIteration bubbling out from generators. I also don't
have a good idea how often this issue bites users, but I have a feeling it
does bite. E.g. this quote from c.l.py (
https://mail.python.org/pipermail/python-list/2014-November/680775.html):

"""
I did find it annoying occasionally that raising StopIteration inside a
generator expression conveys a different behavior than elsewhere. It did
take me quite a while to understand why that is so, but after that it
did not cause me much of a headache anymore.
"""

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141117/63ccfade/attachment.html>


More information about the Python-ideas mailing list