[Python-ideas] Yield-From: Finalization guarantees
Greg Ewing
greg.ewing at canterbury.ac.nz
Sun Mar 29 01:12:05 CET 2009
Nick Coghlan wrote:
> Generators that catch and do anything with GeneratorExit other than turn
> it into StopIteration are almost always going to be broken - the new
> expression needs to avoid making it easy to do that accidentally.
However, as this example shows, the suggested solution
of reraising GeneratorExit is not viable because it
violates the inlining principle.
The basic problem is that there's no way of telling the
difference between a StopIteration that means "it's okay,
I've finalized myself" and "I really mean to return
normally here".
--
Greg
More information about the Python-ideas
mailing list