
On Mon, 14 Sep 2009 07:35:56 am Benjamin Peterson wrote:
Bernie Innocenti <bernie@...> writes:
If we could break the syntax of "print" statements, I'm sure we can also find a satisfactory compromise for CTRL-C handling that won't affect more than 0.1% of existing Python programs.
It would actually be a huge compatibility break because finally statments would no longer be garunteed to execute.
Guarantee not a guarantee :) Finally statements are only guaranteed to execute if the Python process isn't killed or otherwise interrupted. You can kill an unresponsive Python program from the outside, (say) with ctrl-\, and the finally clause never executes:
try: ... t = time.time() ... while 1: ... pass ... finally: ... print "finished infinite loop in %f seconds" % (time.time() - t) ... Quit [steve] $
I think it's worth considering what the OP's real complaint is: namely, that (some? all?) C extensions can't be interrupted by ctrl-C as the user would expect. Is that a valid issue, or is it expected that Python has no control over what happens inside the C extension? -- Steven D'Aprano