This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Ctrl-C causes odd behaviour
Type: Stage:
Components: Windows Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Ctrl-C will exit out of Python interpreter in Windows
View: 1677
Assigned To: Nosy List: mrbax, theller, tlynn
Priority: normal Keywords:

Created on 2004-06-02 11:17 by mrbax, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg20995 - (view) Author: Michael R Bax (mrbax) Date: 2004-06-02 11:17
With various versions of console Python 2.3.x under 
Windows 2000, executed using the "Python (command-
line)" Start Menu shortcut, I have noticed the following 
intermittent errors:

1. When pressing Ctrl-C at the prompt, Python 
terminates.

2. When pressing Ctrl-C during a raw_input, Python 
raises an EOFError instead of KeyboardInterrupt.

I usually cannot duplicate this behaviour by repeatedly 
pressing Ctrl-C or repeating the steps that led to it.
msg20996 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2004-06-09 09:39
Logged In: YES 
user_id=11105

I cannot reproduce this behaviour, so I cannot do anything
on this.
msg20997 - (view) Author: Michael R Bax (mrbax) Date: 2004-06-09 10:21
Logged In: YES 
user_id=1055057

It *is* intermittent.  Try entering the tutorial examples (copy 
and paste) and pressing Ctrl-C at random.  That works for me.

Here's another example: today I rebooted, then later clicked 
on the "Python (command-line)" shortcut.  I typed 1 and 
pressed ENTER.  I then pressed Ctrl-C.

Boom.  Window disappears.

I tried again around 20 times -- it gave a KeyboardInterrupt 
each time, as it should.
msg20998 - (view) Author: Tom Lynn (tlynn) Date: 2004-11-18 22:46
Logged In: YES 
user_id=915320

I just had this too.  Ctrl-C in a raw_input() caused it to
crash with a KeyboardInterrupt associated with the raw_input
line... which would be fine were it not for the fact that
that line was inside a try...except KeyboardInterrupt: pass
(at top level).

Running the same code again behaves properly (exits
silently).  The relevant section of the code was:
try:
    while 1:
        print ">>",
        x = raw_input()
        #...

except KeyboardInterrupt: pass # ctrl-c
except EOFError: pass # ctrl-d/ctrl-z

I'd had the window open for a long time while doing other
things and then woke it with ctrl-C, so it may well be a
"what happens when python is paged out/slow to respond" thing.

This was "Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC
v.1200 32 bit (Intel)] on win32" (Win2k)
msg20999 - (view) Author: Tom Lynn (tlynn) Date: 2004-11-18 23:04
Logged In: YES 
user_id=915320

A quick search for "ctrl-c" turns up these bugs which look
related to me, the last one offers an explanation:

875692 Ctrl-C doesn't work with sleepy main thread
846817 control-c is being sent to child thread rather than main
926423 socket timeouts + Ctrl-C don't play nice
History
Date User Action Args
2022-04-11 14:56:04adminsetgithub: 40330
2008-01-05 18:31:51christian.heimessetstatus: open -> closed
resolution: duplicate
superseder: Ctrl-C will exit out of Python interpreter in Windows
2004-06-02 11:17:47mrbaxcreate