-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Hi,
It does not appear to be currently possible to use the IPython debugger in conjunction with the simple-prompt mode and ipdb (from pypi : pip install ipdb).
This makes debugging multithreaded applications with ipdb and Emacs impossible (since the only way to break in the right thread is to put the snippet: import ipdb; ipdb.set_trace() in the code.
If I remove the "--simple-prompt" option then I get garbled text such as "^[[6n^[[Jipdb> ^[[6D^[[6C" at the ipdb prompt in Emacs since this is a dumb terminal which doesn't understand the special character escapes sent back by prompt_toolkit.
The traceback returned when using "--simple-prompt" is :
[...]
File "some_file.py", line 30, in some_function
import ipdb; ipdb.set_trace()
File "/home/maxim/.virtualenvs/project1/local/lib/python2.7/site-packages/ipdb/__main__.py", line 97, in set_trace
p = _init_pdb(context).set_trace(frame)
File "/home/maxim/.virtualenvs/project1/local/lib/python2.7/site-packages/ipdb/__main__.py", line 77, in _init_pdb
p = debugger_cls(def_colors, context=context)
File "/home/maxim/.virtualenvs/project1/local/lib/python2.7/site-packages/IPython/terminal/debugger.py", line 26, in __init__
self.pt_init()
File "/home/maxim/.virtualenvs/project1/local/lib/python2.7/site-packages/IPython/terminal/debugger.py", line 68, in pt_init
self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self.shell._eventloop)
AttributeError: 'TerminalInteractiveShell' object has no attribute '_eventloop'
It should be trivial to reproduce. Make sure you have ipdb installed (pip install ipdb).
- Create a script such as the following to a file named "ipdb_eventloop_repro.py":
print 'hello'
print ''
import ipdb; ipdb.set_trace()
print 'world'
- In a terminal, start the IPython process in 'simple-prompt' mode like this:
ipython --simple-prompt -c "%run -d ipdb_eventloop_repro.py"
- Then press 'c' to trigger the crash.
I'm not sure where the fix should happen: in IPython, or in ipdb? There was an attempt at fixing it on the ipdb side here: gotcha/ipdb#130 but it causes spewing to restart in the dumb shell since it relies on the prompt_toolkit eventloop.
Any suggestion of a fix? I'd really like to get ipdb + Emacs going :)