classification
Title: Ctrl-C will exit out of Python interpreter in Windows
Type: behavior Stage: test needed
Components: Interpreter Core, Macintosh, Windows Versions: Python 3.3, Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Dude-X, amaury.forgeotdarc, brian.curtin, christian.heimes, r.david.murray, ronaldoussoren, santa4nt
Priority: normal Keywords:

Created on 2007-12-21 06:16 by Dude-X, last changed 2011-03-22 18:27 by santa4nt.

Messages (11)
msg58933 - (view) Author: Isaul Vargas (Dude-X) Date: 2007-12-21 06:16
When running Python 2.5.1 stable in Windows, you can press Ctrl-C as 
many times as you want and it will always output Keyboard Interrupt in 
the interpreter.
Python 3.0a+ will quit if you press ctrl-c too many times. The last 
release of 3.0a2 can handle many interrupts before quitting, but the 
latest snapshot (Dec 20th) can not.

Steps to reproduce:
Run python.exe
hold down ctrl-c, or press it many times. It will quit the interpreter 
eventually.
msg58939 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-12-21 09:44
I don't think it's a critical bug but it may be worth to debug it.
msg58940 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2007-12-21 09:57
I get the same behaviour with python 2.5.1, and even 2.4.4 (on Windows
2000): I hold down Ctrl-C, and after ~30 "KeyboardInterrupt", the
interpreter stops.

So this is not 3.0 specific. What is new in python3.0 is that file
objects are implemented in python, and are much slower.
It is possible that when the key buffer is full, the next Ctrl-C kills
the program. And this is more likely to happen with python3.0.
msg58975 - (view) Author: Isaul Vargas (Dude-X) Date: 2007-12-23 21:03
I wanted to add that this issue also affects python 2.5.1 on the Mac.
Sometimes I may be writing something in the interpreter and I decide to 
invalidate my input by pressing Ctrl-C. This will exit the interpreter 
occasionally. I think it would be a good idea to see if there's a way 
to make the interpreter bullet proof from Ctrl-C, or at least good 
enough so that a single Ctrl-c won't cause the interpreter to exit.
msg89651 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-06-23 23:33
Removing the Windows part: on my machine, repeated Ctrl-C's don't exit the 
3.1 interpreter, probably because the io module is now written in C.
msg89655 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-06-24 05:41
I cannot reproduce this on my machine (running OSX) using 2.5, 2.6 and 3.1  
(latest rc).
msg104643 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-04-30 15:03
Unassigning this issue from myself as I cannot reproduce the issue on OSX.
msg115133 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-27 21:39
I can't reproduce this on windows (in a KVM) with 2.6 or 2.7.
msg115139 - (view) Author: Isaul Vargas (Dude-X) Date: 2010-08-27 22:58
I tested this on a real Windows 7 machine (64 bit, Ultimate)
I open the command prompt, and I have the latest Pythons installed,
Python 2.6.6, Python 2.7 final, and Python 3.1.2
If I hold down Ctrl-C, it will eventually exit the interpreter.
Though it's not normal to hold down Ctrl-C, in practice that means pressing Ctrl-C
to cancel a currently running script may just exit the interpreter.
Python 3.1 seems really terrible in this regard where sometimes a single Ctrl-C will exit the interpreter.

I have seen this issue fixed in Python 2.5.2 on Windows. It would never exit the interpreter no matter how long I pressed Ctrl-C. I don't see this issue in Linux. I don't have a Mac to test, but I'd like Mac users to test the signal handling in their terminals.
msg115155 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-08-28 14:38
I'm not able to reproduce this. Do you have anything installed like pyreadline?
msg131632 - (view) Author: Devin Jeanpierre (Devin Jeanpierre) Date: 2011-03-21 11:07
Windows 7 64-bit (on the metal, not in a VM), can confirm. Holding down Ctrl+C will (eventually) halt Python on all the versions I have installed: 2.3, 2.7, 3.0, 3.1, 3.2. (All of these are 32-bit Pythons). Haven't done anything silly like try to install readline on Windows.

I also tried it on cygwin Python (2.6), held down for maybe 20 seconds, didn't crash.
History
Date User Action Args
2011-03-22 18:27:28santa4ntsetnosy: + santa4nt, - Devin Jeanpierre
versions: + Python 3.2, Python 3.3
2011-03-21 11:07:31Devin Jeanpierresetnosy: + Devin Jeanpierre
messages: + msg131632
2010-08-28 14:38:50brian.curtinsetversions: - Python 2.6
nosy: + brian.curtin

messages: + msg115155

assignee: ronaldoussoren ->
2010-08-27 22:58:30Dude-Xsetversions: + Python 2.7
nosy: ronaldoussoren, amaury.forgeotdarc, christian.heimes, Dude-X, r.david.murray
messages: + msg115139

assignee: ronaldoussoren
components: + Interpreter Core, Windows
2010-08-27 21:39:55r.david.murraysetnosy: + r.david.murray
messages: + msg115133
2010-04-30 15:03:39ronaldoussorensetassignee: ronaldoussoren -> (no value)

messages: + msg104643
nosy: + ronaldoussoren
2009-09-06 14:31:21ronaldoussorensetnosy: - ronaldoussoren
2009-06-24 05:41:10ronaldoussorensetmessages: + msg89655
2009-06-23 23:33:14amaury.forgeotdarcsetnosy: + ronaldoussoren
messages: + msg89651

assignee: ronaldoussoren
components: + Macintosh, - Interpreter Core, Windows
2009-04-27 23:37:03ajaksu2setstage: test needed
versions: + Python 3.1, - Python 2.5, Python 2.4, Python 3.0
2008-01-06 22:29:44adminsetkeywords: - py3k
versions: Python 2.6, Python 2.5, Python 2.4, Python 3.0
2008-01-05 18:31:51christian.heimeslinkissue964949 superseder
2008-01-03 20:25:14JosephArmbrustersetcomponents: + Windows
2007-12-23 21:03:11Dude-Xsetmessages: + msg58975
versions: + Python 2.6, Python 2.5, Python 2.4
2007-12-21 09:57:40amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg58940
2007-12-21 09:44:11christian.heimessetpriority: normal
keywords: + py3k
messages: + msg58939
nosy: + christian.heimes
2007-12-21 06:16:12Dude-Xcreate