Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipython5 use TerminalInteractiveShell debugger_cls solution for #105 #108

Merged
merged 2 commits into from
Jan 25, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ipdb/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ def import_module(possible_modules, needed_module):
raise
try:
# IPython 5.0 and newer
from IPython.terminal.debugger import TerminalPdb as Pdb
from IPython.core.debugger import BdbQuit_excepthook
from IPython.terminal.interactiveshell import TerminalInteractiveShell
debugger_cls = TerminalInteractiveShell().debugger_cls
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively I was going to define it as a function rather than at import time, which now that I think about it, sounds much better.

except ImportError:
from IPython.core.debugger import Pdb, BdbQuit_excepthook
debugger_cls = Pdb

possible_modules = ['IPython.terminal.ipapp', # Newer IPython
'IPython.frontend.terminal.ipapp'] # Older IPython
Expand Down Expand Up @@ -70,10 +72,10 @@ def import_module(possible_modules, needed_module):


def _init_pdb(context=3):
if 'context' in getargspec(Pdb.__init__)[0]:
p = Pdb(def_colors, context=context)
if 'context' in getargspec(debugger_cls.__init__)[0]:
p = debugger_cls(def_colors, context=context)
else:
p = Pdb(def_colors)
p = debugger_cls(def_colors)
p.rcLines += def_exec_lines
return p

Expand Down