[issue26531] KeyboardInterrupt while in input() not catchable on Windows 10

Joshua Cannell report at bugs.python.org
Fri Mar 11 11:14:12 EST 2016


Joshua Cannell added the comment:

Yeah, so this looks like a behavior in Windows in which an EOFError is raised when a Ctrl + C is pressed, followed by a KeyboardInterrupt.

This post basically explains how to overcome it: http://stackoverflow.com/questions/31127652/cannot-catch-keyboardinterrupt-in-command-prompt-twice

def bing():
    try:
        input()
    except EOFError:
        print("Caught an EOFError")

try:
    bing()
    print("After bing")
except KeyboardInterrupt:
    print("Final KeyboardInterrupt")

Sorry for necro-ing an old issue.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26531>
_______________________________________


More information about the Python-bugs-list mailing list