homepage

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.

Author Josh.Hanson
Recipients Josh.Hanson
Date 2011年01月05日.20:02:04
SpamBayes Score 1.5966367e-10
Marked as misclassified No
Message-id <1294257725.97.0.863829105509.issue10837@psf.upfronthosting.co.za>
In-reply-to
Content
Example code:
 try:
 sys.stdin.read()
 except KeyboardInterrupt:
 print "Interrupted!"
 except:
 print "Some other exception?"
 finally:
 print "cleaning up..."
 print "done."
Test: run the code and hit ctrl-c while the read is blocking.
Expected behavior: program should print:
 Interrupted!
 cleaning up...
 done.
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:
 try:
 sys.stdin.read()
 print "Done reading."
 ... [etc.]
Then this is the output:
 Done reading. Interrupted!
 cleaning up...
 done.
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.
History
Date User Action Args
2011年01月05日 20:02:06Josh.Hansonsetrecipients: + Josh.Hanson
2011年01月05日 20:02:05Josh.Hansonsetmessageid: <1294257725.97.0.863829105509.issue10837@psf.upfronthosting.co.za>
2011年01月05日 20:02:04Josh.Hansonlinkissue10837 messages
2011年01月05日 20:02:04Josh.Hansoncreate

AltStyle によって変換されたページ (->オリジナル) /