KeybordInterrupts and friends

aurelien.campeas at free.fr aurelien.campeas at free.fr
Wed Apr 26 05:41:54 EDT 2006


Hello,

I have a problem with the following code fragment :

--------------------
import sys

while True:
    try:
        raw_input()
    except EOFError:
        print "C-d"
    except KeyboardInterrupt:
        print "C-c"
--------------------

The following behaviour seems bogus to me :

auc at musca:~$ python test.py
C-c
C-c
C-d
C-d
Traceback (most recent call last):
  File "test.py", line 5, in ?
    raw_input()
KeyboardInterrupt

The crash happens when I type C-c another time (always *after* atleast
one C-d has been issued).

What's wrong ? My expectations ? CPython (2.3 and 2.4 on debian exhibit
the same problem).
Is this a FAQ ?

Thanks,
Aurélien.




More information about the Python-list mailing list