On Fri, 16 Feb 2007 01:47:43 -0800, ruka_at_ wrote: > Hi, > why is KeyboardInterrupt not caught (xp)? > import sys > try: > inp = sys.stdin.read() > except (KeyboardInterrupt, SystemExit): > print "kbd-interr,SystemExit" > except EOFError: > print "eof encountered"
I don't think you ever get an EOFError from stdin. If you type ^D immediately, stdin.read() returns an empty string. > except: > print "caught all" > self.showtraceback() I don't imagine you'll get any other exceptions either. Not that it matters, but what's self? > print "normal end" > > result after script startet and ^C hit: >>ctrl_test.py > normal end > Traceback (most recent call last): > File "C:\work\py_src\ctrl_test.py", line 11, in ? > print "normal end" > KeyboardInterrupt It works as expected for me. I seem to have a vague recollection that the keyboard interrupt under Windows isn't ^C but something else... ^Z maybe? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list