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

Georg Brandl g.brandl at gmx.net
Mon Nov 17 10:26:13 CET 2014


On 11/17/2014 03:11 AM, Chris Angelico wrote:
> On Mon, Nov 17, 2014 at 12:58 PM, Guido van Rossum <guido at python.org> wrote:
>> I agree with you and Steven that this is a fine use of __future__. What a
>> generator does with a StopIteration that is about to bubble out of its frame
>> is up to that generator. I don't think it needs to be a flag on the
>> *function* though -- IMO it should be a flag on the code object. (And the
>> flag should somehow be transferred to the stack frame when the function is
>> executed, so the right action can be taken when an exception is about to
>> bubble out of that frame.)
>>
>> One other small point: let's change the PEP to just propose RuntimeError,
>> and move the "some other exception" to the "rejected ideas" section.
> 
> Changes incorporated, thanks! I'm not familiar with the details of
> stack frame handling, so I've taken the cop-out approach and just
> quoted you directly into the PEP.
> 
> PEP draft:
> https://raw.githubusercontent.com/Rosuav/GenStopIter/master/pep-0479.txt

I fixed a typo and syntax and made a content clarification ("generator
constructed" -> "generator function constructed"; the generator object
itself is constructed when the function is called) and committed the changes.

Georg



More information about the Python-ideas mailing list