j: Next unread message
k: Previous unread message
j a: Jump to all threads
j l: Jump to MailingList overview
Should GeneratorExit inherit from Exception or BaseException?
Currently, a generator that catches Exception and continues on to yield another value can't be closed properly (you get a runtime error pointing out that the generator ignored GeneratorExit).
The only decent reference I could find to it in the old PEP 348/352 discussions is Guido writing :
when GeneratorExit or StopIteration reach the outer level of an app, it's a bug like all the others that bare 'except:' WANTS to catch.
(at that point in the conversation, I believe bare except was considered the equivalent of "except Exception:")
While I agree with what Guido says about GeneratorExit being a bug if it reaches the outer level of an app, it seems like a bit of a trap that a correctly written generator can't write "except Exception:" without preceding it with an "except GeneratorExit:" that reraises the exception. Isn't that exactly the idiom we're trying to get rid of for SystemExit and KeyboardInterrupt?