From d23b766be46990e6015d6e821cfb293eb52b9528 Mon Sep 17 00:00:00 2001 From: tdashelby-cmyk <253610080+tdashelby-cmyk@users.noreply.github.com> Date: Mon, 11 May 2026 16:42:57 +0200 Subject: [PATCH] Accept singular pdb exception command --- IPython/core/debugger.py | 6 ++++++ tests/test_debugger.py | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index 4afd86427de..b35a2cd345e 100644 --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -515,6 +515,12 @@ def do_exceptions(self, arg): else: self.error("No exception with that number") + def do_exception(self, arg): + """exception [number] + Alias for the ``exceptions`` command. + """ + return self.do_exceptions(arg) + def interaction(self, frame, tb_or_exc): try: if CHAIN_EXCEPTIONS: diff --git a/tests/test_debugger.py b/tests/test_debugger.py index acfabe76060..ecc2f17e3c4 100644 --- a/tests/test_debugger.py +++ b/tests/test_debugger.py @@ -279,6 +279,19 @@ def raising_input(msg="", called=[0]): sys.settrace(tracer_orig) +@pytest.mark.skipif( + not debugger.CHAIN_EXCEPTIONS, + reason="chained exception navigation is not available", +) +def test_exception_command_aliases_exceptions(): + ipdb = debugger.Pdb() + + with patch.object(ipdb, "do_exceptions", return_value=True) as do_exceptions: + assert ipdb.onecmd("exception 0") is True + + do_exceptions.assert_called_once_with("0") + + @skip_win32 def test_xmode_skip(): """that xmode skip frames