New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MS WINDOWS: input() swallows KeyboardInterrupt in Python 3.3 #61819
Comments
At least on Windows, input() doesn't raise KeyboardInterrupt when Ctrl-C is hit in Python 3.3 (it does in Python 3.2). 3.3:
>>> x = input() # Ctrl-C hit - no exception raised
>>> x
NameError
3.2:
>>> x = input() # Ctrl-C hit
KeyboardInterrupt |
Seems to be windows specific. It works fine on Linux and Solaris. |
It may be related to the following commit: changeset: 77861:9523c122d6fc |
@Drekin: What is your Windows version? How did you start Python? |
I have Windows Vista Business SP2, 64-bit, (6.0.6002). If I start Python any way (from console, from shortcut, via py.exe or not) the same behavior occurs. |
However it raises the exception correctly in IDLE. The same behavior occured on Windows 7 Home Premium SP1, 64-bit, (6.1.7601). |
That's because IDLE uses a completely different input loop from the I'll try to get to this but I'm chock-a-block with other work at the |
There is related weird behavior: >>> try:
... input()
... except KeyboardInterrupt:
... print("exception occured")
...
# Ctrl-C hit
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
KeyboardInterrupt
>>> Seems like handling of Ctrl-C is kind of “out of sync”. |
Maybe this is related to
which causes PyTraceback_Print() to fail if a signal is received but PyErr_CheckSignals() has not been called. Note that wrapping in "try: ... except: raise" makes a traceback appear: >>> try: input()
... except: raise
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyboardInterrupt |
Adding PyErr_CheckSignals() after PyOS_Readline() in builtin_input() seems to fix the problem. |
+1 Richard - are you in a position to commit / push? |
New changeset 241cd716bf5f by Richard Oudkerk in branch '3.3': |
Done. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: