29 Mar
2009
29 Mar
'09
1:12 a.m.
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