From 3ad65eb369cd8aa05c17a85e761fe8ab54558295 2016-09-19 17:37:08 From: Fernando Perez Date: 2016-09-19 17:37:08 Subject: [PATCH] Merge pull request #9950 from mbyt/enable_quit_for_debugging_with_minus_m_IPython.terminal.debugger Enable quitting for -m IPython.terminal.debugger, which would otherwise unconditionally trap all attempts at exiting. --- diff --git a/IPython/terminal/debugger.py b/IPython/terminal/debugger.py index 821a45b..e7bd135 100644 --- a/IPython/terminal/debugger.py +++ b/IPython/terminal/debugger.py @@ -86,5 +86,11 @@ def set_trace(frame=None): if __name__ == '__main__': import pdb + # IPython.core.debugger.Pdb.trace_dispatch shall not catch + # bdb.BdbQuit. When started through __main__ and an exception + # happened after hitting "c", this is needed in order to + # be able to quit the debugging session (see #9950). + old_trace_dispatch = pdb.Pdb.trace_dispatch pdb.Pdb = TerminalPdb + pdb.Pdb.trace_dispatch = old_trace_dispatch pdb.main()