From 1bc1ac51931020f17f4542e4f5b96c83f9b0d2a3 2021-04-16 19:18:04 From: Iwan Briquemont Date: 2021-04-16 19:18:04 Subject: [PATCH] Start embedded IPython shell for ipdb interact, #12913 --- diff --git a/IPython/terminal/debugger.py b/IPython/terminal/debugger.py index dd1ecc1..00ff516 100644 --- a/IPython/terminal/debugger.py +++ b/IPython/terminal/debugger.py @@ -7,6 +7,7 @@ from IPython.core.debugger import Pdb from IPython.core.completer import IPCompleter from .ptutils import IPythonPTCompleter from .shortcuts import create_ipython_shortcuts +from . import embed from pygments.token import Token from prompt_toolkit.shortcuts.prompt import PromptSession @@ -131,6 +132,18 @@ class TerminalPdb(Pdb): except Exception: raise + def do_interact(self, arg): + ipshell = embed.InteractiveShellEmbed( + config=self.shell.config, + banner1="*interactive*", + exit_msg="now exiting InteractiveConsole...", + ) + global_ns = self.curframe.f_globals + ipshell( + module=sys.modules.get(global_ns["__name__"], None), + local_ns=self.curframe_locals, + ) + def set_trace(frame=None): """ diff --git a/docs/source/whatsnew/pr/ipdb-interact.rst b/docs/source/whatsnew/pr/ipdb-interact.rst new file mode 100644 index 0000000..8783be6 --- /dev/null +++ b/docs/source/whatsnew/pr/ipdb-interact.rst @@ -0,0 +1,4 @@ +IPython shell for ipdb interact +------------------------------- + +The ipdb ``interact`` starts an IPython shell instead of Python's built-in ``code.interact()``.