[New-bugs-announce] [issue10837] Issue catching KeyboardInterrupt while reading stdin
report at bugs.python.org
Wed Jan 5 21:02:05 CET 2011
New submission from Josh Hanson <surely.you.jest at gmail.com>:
print "Some other exception?"
print "cleaning up..."
Test: run the code and hit ctrl-c while the read is blocking.
Expected behavior: program should print:
Actual behavior: On linux, behaves as expected. On windows, prints:
Traceback (most recent call last):
File "filename.py", line 119, in <module>
print 'cleaning up...'
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:
print "Done reading."
Then this is the output:
Done reading. Interrupted!
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.
components: IO, Windows
title: Issue catching KeyboardInterrupt while reading stdin
versions: Python 2.6, Python 2.7, Python 3.1
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce