[Python-Dev] Pre-PEP: Exception Reorganization for Python 3.0
Phillip J. Eby
pje at telecommunity.com
Sun Jul 31 18:15:54 CEST 2005
At 05:05 PM 7/31/2005 +1000, Nick Coghlan wrote:
>Brett Cannon wrote:
> >>Notice that I've classified KeyboardInterrupt as user-initiated control
> flow
> >>and put it under ControlFlowException above. This means that everything
> under
> >>CriticalError and Error actually ends with the word 'Error'.
> >
> > I don't know if I like this change in inheritance. While we do tend
> > to use KeyboardInterrupt as a way to kill a program, is that really
> > control flow, or a critical exception that the program needs to stop
> > because an serious event occurred?
> >
> > I prefer the latter explanation.
>
>You're probably right. How does the following reasoning sound:
>
>SystemExit, GeneratorExit and StopIteration are all deliberately triggered by
>certain well-defined elements of normal application code. That is, only
>certain operations will ever result in a ControlFlowException being raised.
>
>KeyboardInterrupt is a better fit with MemoryError and SystemError -
>something
>that occurs unexpectedly, at an arbitary point during program execution. That
>is, a CriticalError may be raised when attempting to execute almost any
>operation.
Ugh. A KeyboardInterrupt isn't an error, let alone a critical one. The
fact that it occurs unexpectedly has nothing to do with it. A
CriticalError needs different treatment than a KeyboardInterrupt for things
like logging, notifications, etc. Heck, it needs different treatment just
because a KeyboardInterrupt is something you can sanely recover from and
gracefully shut down with. The odds of you recovering from an actual
CriticalError are negligible.
It's not the same thing, no matter what explanation you prefer. ;)
More information about the Python-Dev
mailing list