[Python-Dev] Problems with GeneratorExit deriving from Exception

Nick Coghlan ncoghlan at gmail.com
Sun Dec 2 16:21:39 CET 2007


Guido van Rossum wrote:
> Well argued. I suggest to go for option (1) -- make GeneratorExit
> inherit from BaseException. We can do this starting 2.6. Feel free to
> upload a patch to bugs.python.org.

It actually took me a while to figure out why this use case was 
convincing, when the same idea had been rejected for 2.5.

For anyone else as slow as me: in the hypothetical examples I posted 
before the release of 2.5, the yield could be moved to an else clause on 
the try-except statement without adversely affecting the semantics.

The use case Chad presented here is different, because the exceptions to 
be handled are being passed back in via the yield expression - moving it 
would defeat the whole purpose of the exception handling. I'm sure the 
fact that the example comes from a real application rather than the 
'what-if' generator in my brain helps a lot too :)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list