[Python-Dev] PEP 479: Change StopIteration handling inside generators (original) (raw)
Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Nov 25 01:21:32 CET 2014
- Previous message: [Python-Dev] PEP 479: Change StopIteration handling inside generators
- Next message: [Python-Dev] PEP 479: Change StopIteration handling inside generators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Nov 19, 2014 at 3:10 PM, Guido van Rossum <guido at python.org> wrote:
There's a new PEP proposing to change how to treat StopIteration bubbling up out of a generator frame (not caused by a return from the frame). The proposal is to replace such a StopIteration with a RuntimeError (chained to the original StopIteration), so that only returning from a generator (or falling off the end) causes the iteration to terminate.
I think the PEP should also specify what will happen if the generator's next() method is called again after RuntimeError is handled. The two choices are:
- Raise StopIteration (current behavior for all exceptions).
- Raise RuntimeError (may be impossible without gi_frame).
I think choice 1 is implied by the PEP. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20141124/2fb96433/attachment.html>
- Previous message: [Python-Dev] PEP 479: Change StopIteration handling inside generators
- Next message: [Python-Dev] PEP 479: Change StopIteration handling inside generators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]