##// END OF EJS Templates
IPython/lib/editorhooks.py: wait for process even if wait=False...
IPython/lib/editorhooks.py: wait for process even if wait=False The wait parameter is meant to add a prompt before returning from the hook for editors that exit immediatly (fork/CreateProcess) but it accidently prevented waiting at all for the process when it was False. I think it was meant to be `not wait and proc.wait()` but we might as well wait for the process in the `wait=True` case anyhow. It's less confusing.

File last commit:

r23274:0f79628c
r23294:7e3493b7
Show More
debugger.py
98 lines | 3.5 KiB | text/x-python | PythonLexer
Thomas Kluyver
Create separate class for debugger using prompt_toolkit
r22391 from IPython.core.debugger import Pdb
from IPython.core.completer import IPCompleter
from .ptutils import IPythonPTCompleter
from prompt_toolkit.token import Token
from prompt_toolkit.shortcuts import create_prompt_application
from prompt_toolkit.interface import CommandLineInterface
from prompt_toolkit.enums import EditingMode
tillahoffmann
Add frame parameter to terminal debugger.
r22874 import sys
Thomas Kluyver
Create separate class for debugger using prompt_toolkit
r22391
class TerminalPdb(Pdb):
def __init__(self, *args, **kwargs):
Pdb.__init__(self, *args, **kwargs)
self._ptcomp = None
self.pt_init()
def pt_init(self):
def get_prompt_tokens(cli):
return [(Token.Prompt, self.prompt)]
Thomas Kluyver
Fix error tab completing in the debugger...
r23274 def patch_stdout(**kwargs):
return self.pt_cli.patch_stdout_context(**kwargs)
Thomas Kluyver
Create separate class for debugger using prompt_toolkit
r22391 if self._ptcomp is None:
compl = IPCompleter(shell=self.shell,
namespace={},
global_namespace={},
parent=self.shell,
)
Thomas Kluyver
Fix error tab completing in the debugger...
r23274 self._ptcomp = IPythonPTCompleter(compl, patch_stdout=patch_stdout)
Thomas Kluyver
Create separate class for debugger using prompt_toolkit
r22391
self._pt_app = create_prompt_application(
editing_mode=getattr(EditingMode, self.shell.editing_mode.upper()),
history=self.shell.debugger_history,
completer= self._ptcomp,
enable_history_search=True,
mouse_support=self.shell.mouse_support,
get_prompt_tokens=get_prompt_tokens
)
self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self.shell._eventloop)
def cmdloop(self, intro=None):
"""Repeatedly issue a prompt, accept input, parse an initial prefix
off the received input, and dispatch to action methods, passing them
the remainder of the line as argument.
override the same methods from cmd.Cmd to provide prompt toolkit replacement.
"""
if not self.use_rawinput:
raise ValueError('Sorry ipdb does not support use_rawinput=False')
self.preloop()
try:
if intro is not None:
self.intro = intro
if self.intro:
self.stdout.write(str(self.intro)+"\n")
stop = None
while not stop:
if self.cmdqueue:
line = self.cmdqueue.pop(0)
else:
self._ptcomp.ipy_completer.namespace = self.curframe_locals
self._ptcomp.ipy_completer.global_namespace = self.curframe.f_globals
try:
line = self.pt_cli.run(reset_current_buffer=True).text
except EOFError:
line = 'EOF'
line = self.precmd(line)
stop = self.onecmd(line)
stop = self.postcmd(stop, line)
self.postloop()
except Exception:
raise
Matthias Bussonnier
Make clearer and simpler how to user prompt-toolkit PDB...
r22724
tillahoffmann
Add frame parameter to terminal debugger.
r22874
def set_trace(frame=None):
"""
Start debugging from `frame`.
If frame is not specified, debugging starts from caller's frame.
"""
TerminalPdb().set_trace(frame or sys._getframe().f_back)
Matthias Bussonnier
Make clearer and simpler how to user prompt-toolkit PDB...
r22724
mbyt
-m IPython.terminal.debugger...
r22858
if __name__ == '__main__':
import pdb
mbyt
enable quitting for -m IPython.terminal.debugger
r22879 # IPython.core.debugger.Pdb.trace_dispatch shall not catch
mbyt
fixing typo in comment
r22901 # bdb.BdbQuit. When started through __main__ and an exception
mbyt
fixing another typo in comment
r22902 # happened after hitting "c", this is needed in order to
mbyt
enable quitting for -m IPython.terminal.debugger
r22879 # be able to quit the debugging session (see #9950).
old_trace_dispatch = pdb.Pdb.trace_dispatch
mbyt
-m IPython.terminal.debugger...
r22858 pdb.Pdb = TerminalPdb
mbyt
enable quitting for -m IPython.terminal.debugger
r22879 pdb.Pdb.trace_dispatch = old_trace_dispatch
mbyt
-m IPython.terminal.debugger...
r22858 pdb.main()