[Python-Dev] Pre-PEP: Exception Reorganization for Python 3.0

Willem Broekema metawilm at gmail.com
Sun Jul 31 12:36:47 CEST 2005


On 7/31/05, Brett Cannon <bcannon at gmail.com> wrote:
> 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 does not seem right to me to think of KeyboardInterrupt as a means
to cause program halting. An interpreter could in principle recover
from it and resume execution of the program.

The behaviour of the current Python interpreters is that upon
encountering an uncaught KeyboardInterrupt (as with any uncaught
exception), computation is aborted and a backtrace printed. But that
is not how it /must be/ as there might be alternative interpreters
that upon encountering an uncaught KeyboardInterrupt will pause
execution of the program, but then allow the user to either continue
or abort execution, effectively not stopping but pausing the program.

Because of this possible recovery, thinking of KeyboardInterrupt as
"in order to abort the program, the user has caused a keyboard
interrupt" is wrong; it should be more like just "the user has
interrupted the computation" and whether or not the program is
consequently aborted is not predefined.

- Willem


More information about the Python-Dev mailing list