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

Chris Angelico rosuav at gmail.com
Mon Nov 17 03:11:15 CET 2014


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

GitHub hosted repo, if you want to follow changes etc:
https://github.com/Rosuav/GenStopIter

ChrisA


More information about the Python-ideas mailing list