-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Issue catching KeyboardInterrupt while reading stdin #55046
Comments
Example code: Test: run the code and hit ctrl-c while the read is blocking. Actual behavior: On linux, behaves as expected. On windows, prints:
cleaning up...
Traceback (most recent call last):
File "filename.py", line 119, in <module>
print 'cleaning up...'
KeyboardInterrupt As you can see, neither of the "except" blocks was executed, and the "finally" block was erroneously interrupted. If I add one line inside the try block, as follows: Then this is the output: Here, the exception handler and finally block were executed as expected. This is still mildly unusual because the "done reading" print statement was reached when it probably shouldn't have been, but much more surprising because a newline was not printed after "Done reading.", and for some reason a space was. This has been tested and found in 32-bit python versions 2.6.5, 2.6.6, 2.7.1, and 3.1.3 on 64-bit Win7. |
I can confirm this behavior on 2.7. On 3.2 for me it prints "done.", but not "Interrupted!" |
Sorry, forgot to mention my system. 64-bit Windows 7. |
I can confirm that this works fine with 3.4.1 and 3.5.0a0. I don't run 2.7 any more so I don't know if this is fixed in later versions. |
Python 2-only issue. |
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: