[Python-ideas] Yield-From: Finalization guarantees

Bruce Frederiksen dangyogi at gmail.com
Tue Mar 31 16:09:50 CEST 2009

Nick Coghlan wrote:
> 4, 3, 2, 1 is the position I've come around to. [...]
What he said.

I think that 4 also has the advantage of raising RuntimeError in the 
inner generator's close method (using the definition of close provided 
in PEP 342) when the inner generator doesn't obey the rules for 
GeneratorExit laid out in PEP 342.  Throwing GeneratorExit to the inner 
generator causes the outer generator's close to report the RuntimeError, 
which pins the blame on the wrong generator (in the stack traceback, 
which won't even show the inner generator).

-bruce frederiksen

More information about the Python-ideas mailing list