From 1ed207686d2a5e4759501012e6ddc89d9d09e7d4 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 26 Mar 2020 14:40:34 -0400 Subject: Since runcode() catches most KeyboardInterrupts, just ignore any that make their way up to our code. This is more consistent than raising the rare few that we see. --- cmd2/cmd2.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 84a1ce67..1c733843 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1685,9 +1685,9 @@ class Cmd(cmd.Cmd): if py_bridge_call: # Stop saving command's stdout before command finalization hooks run self.stdout.pause_storage = True - except KeyboardInterrupt as e: + except KeyboardInterrupt as ex: if raise_keyboard_interrupt: - raise e + raise ex except (Cmd2ArgparseError, EmptyStatement): # Don't do anything, but do allow command finalization hooks to run pass @@ -3255,10 +3255,8 @@ class Cmd(cmd.Cmd): # noinspection PyBroadException try: interp.runcode(py_code_to_run) - except KeyboardInterrupt as e: - raise e except BaseException: - # We don't care about any other exceptions that happened in the Python code + # We don't care about any exceptions that happened in the Python code pass # Otherwise we will open an interactive Python shell -- cgit v1.2.1