[Python-ideas] Yield-From: GeneratorExit?

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Mar 23 01:49:49 CET 2009


Nick Coghlan wrote:

> All I'm saying is that if GeneratorExit doesn't get passed down then
> neither should SystemExit nor KeyboardInterrupt

That would violate the inlining principle, though.
An inlined generator is going to get all exceptions
regardless of what they inherit from.

>, while if the latter two
> *do* get passed down, then so should GeneratorExit.

Whereas that would mean a shared subiterator would
get prematurely finalized when closing the delegating
generator.

So there seems to be no choice about this -- we must
pass on all exceptions except GeneratorExit, and we
must *not* pass on GeneratorExit itself.

-- 
Greg



More information about the Python-ideas mailing list