[Python-Dev] Proposal - KeyboardInterrupt should inherit directly from Exception

Michael Hudson mwh@starship.python.net
Thu, 08 Nov 2001 05:24:53 -0500


Skip Montanaro <montanaro@tttech.com> writes:

> [KeyboardInterrupt]

Parenthetically, could someone explain why this doesn't work[1]:

>>> import signal
>>> def interrupt(signum, frame):
...     sys.exit(1)
...
>>> signal.signal(signal.SIGINT, interrupt)
<built-in function default_int_handler>
>>> ^C
KeyboardInterrupt
>>> ^C
KeyboardInterrupt
>>> ^C
KeyboardInterrupt

and yet:

>>> def testit():
...     signal.signal(signal.SIGINT, interrupt)
...     while 1:
...         pass
...
>>> testit()
^C[mwh@starship mwh]$

I think I hate readline.

Cheers,
M.

[1] Actually I know, on thinking about it, but it still sucks.
    Is this worth working around?

-- 
  You have run into the classic Dmachine problem: your machine has
  become occupied by a malevolent spirit.  Replacing hardware or
  software will not fix this - you need an exorcist. 
                                       -- Tim Bradshaw, comp.lang.lisp