[Python-Dev] GeneratorExit inheriting from Exception

Giovanni Bajo rasky at develer.com
Sun Mar 19 12:43:33 CET 2006


Nick Coghlan <ncoghlan at gmail.com> wrote:

> Rather than trying to change course midstream, I *like* the fact that
> the PEP 352 hierarchy introduces BaseException to bring the language
> itself into line with what people have already been taught. Breaking
> things in Py3k is all well and good, but breaking them gratuitously
> is something else entirely :)

I really like this too, but Barry's proposal doesn't really *break* anything.
Existing Python code that creates a FooBar(Exception) and then catches it with
either "except FooBar:" or "except Exception, e:" + check for FooBar, will
still work as expected. At *worse*, it would be catching too much, like
SystemExit or GeneratorExit, which are still pretty uncommon exception.

OTOH, I also understand that people have been told that deriving from Exception
is the right thing to do forever now.

Giovanni Bajo



More information about the Python-Dev mailing list