From c2a64546cbab6a4690b1635b3785279cecb24c4e Mon Sep 17 00:00:00 2001 From: Sam Colwell Date: Sat, 12 Jan 2019 14:48:45 -0500 Subject: [PATCH] Add try block around stdin.read for cygwin --- py65/utils/console.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/py65/utils/console.py b/py65/utils/console.py index 59d4b56..3c7c67c 100644 --- a/py65/utils/console.py +++ b/py65/utils/console.py @@ -60,7 +60,6 @@ else: except: # Quietly ignore termios errors, such as stdin not being # a tty. - print("DEBUG: Exception getting termios settings") pass def noncanonical_mode(stdin): @@ -115,9 +114,15 @@ else: noncanonical_mode(stdin) # If we didn't get a character, ask again. while char == '': - char = stdin.read(1) - # stdin has already been set up with a 0.1s delay, so we - # don't need an additional delay here. + try: + char = stdin.read(1) + # stdin has already been set up with a 0.1s delay, so we + # don't need an additional delay here. + except KeyboardInterrupt: + # Pass along a CTRL-C interrupt. + raise + except: + pass return char def getch_noblock(stdin): @@ -128,7 +133,13 @@ else: # Using non-blocking read noncanonical_mode(stdin) - char = stdin.read(1) + try: + char = stdin.read(1) + except KeyboardInterrupt: + # Pass along a CTRL-C interrupt. + raise + except: + pass if char == "\n": char = "\r"