On Mon, Mar 30, 2009 at 5:12 PM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
Nick Coghlan wrote:
Well, in theory people are meant to be writing "except Exception:" rather than using a bare except or catching BaseException - that's a big part of the reason SystemExit, KeyboardInterrupt and GeneratorExit *aren't* Exception subclasses.
Yes, it probably isn't something people will do very often. But as long as GeneratorExit is documented as an official part of the language, we need to explain how we're dealing with it.
BTW, how official *is* it meant to be? There seems to be very little said about it in either the Language or Library Reference.
That's one of our many doc bugs. (Maybe someone at the PyCon sprints can fix these?) PEP 342 defines GeneratorExit, inheriting from Exception. However a later change to the code base made it inherit from BaseException.
The Library Ref says it's the "exception raised when a generator's close() method is called". The Language Ref says that the close() method "allows finally clauses to run", but doesn't say how that is accomplished.
And I can't find throw() mentioned anywhere!
Also defined in PEP 342. -- --Guido van Rossum (home page: http://www.python.org/~guido/)