From fc235985508d0431192405b46c6fbfb209069048 2022-05-03 00:36:53 From: telamonian Date: 2022-05-03 00:36:53 Subject: [PATCH] fix uncaught `BdbQuit` exceptions on ipdb `exit` - `BdbQuit` is now handled in the top-most scope of `InteractiveShell.run_code`. This ensures that `BdbQuit` is correctly handled but can still do its job of breaking out of all user code/loops/further breakpoint requests. Hopefully will work better than previous attempts, which put the `BdqQuit` handling in `Pdb.set_trace` - fixes: - jupyterlab/jupyterlab#12501 - refs: - ipython/ipython#876 - ipython/ipython#1273 - ipython/ipython#4474 - ipython/ipython#5306 - ipython/ipython#9731 - ipython/ipython#9942 - ipython/ipython#9950 - ipython/ipython#10006 - ipython/ipython#12378 --- diff --git a/.gitignore b/.gitignore index 5b45fd4..f473653 100644 --- a/.gitignore +++ b/.gitignore @@ -28,5 +28,13 @@ __pycache__ .pytest_cache .python-version venv*/ -.idea/ .mypy_cache/ + +# jetbrains ide stuff +*.iml +.idea/ + +# vscode ide stuff +*.code-workspace +.history +.vscode diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index 8e3dd96..ba12e3e 100644 --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -101,7 +101,6 @@ All the changes since then are under the same license as IPython. # #***************************************************************************** -import bdb import inspect import linecache import sys diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index ea9f631..371a3da 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -14,6 +14,7 @@ import abc import ast import atexit +import bdb import builtins as builtin_mod import dis import functools @@ -3403,6 +3404,11 @@ class InteractiveShell(SingletonConfigurable): result.error_in_exec = e self.showtraceback(exception_only=True) warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1) + except bdb.BdbQuit: + etype, value, tb = sys.exc_info() + if result is not None: + result.error_in_exec = value + # the BdbQuit stops here except self.custom_exceptions: etype, value, tb = sys.exc_info() if result is not None: