Skip to content

Commit 1ed2076

Browse files
committed
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.
1 parent cb0726e commit 1ed2076

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

cmd2/cmd2.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,9 +1685,9 @@ def onecmd_plus_hooks(self, line: str, *, add_to_history: bool = True,
16851685
if py_bridge_call:
16861686
# Stop saving command's stdout before command finalization hooks run
16871687
self.stdout.pause_storage = True
1688-
except KeyboardInterrupt as e:
1688+
except KeyboardInterrupt as ex:
16891689
if raise_keyboard_interrupt:
1690-
raise e
1690+
raise ex
16911691
except (Cmd2ArgparseError, EmptyStatement):
16921692
# Don't do anything, but do allow command finalization hooks to run
16931693
pass
@@ -3255,10 +3255,8 @@ def py_quit():
32553255
# noinspection PyBroadException
32563256
try:
32573257
interp.runcode(py_code_to_run)
3258-
except KeyboardInterrupt as e:
3259-
raise e
32603258
except BaseException:
3261-
# We don't care about any other exceptions that happened in the Python code
3259+
# We don't care about any exceptions that happened in the Python code
32623260
pass
32633261

32643262
# Otherwise we will open an interactive Python shell

0 commit comments

Comments
 (0)