diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index 4afd86427d..b35a2cd345 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 acfabe7606..ecc2f17e3c 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