Skip to content

Commit

Permalink
Move debugger_cls one class higher
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Mar 27, 2022
1 parent 8b55158 commit 43fd878
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions IPython/core/ultratb.py
Expand Up @@ -207,7 +207,16 @@ class TBTools(colorable.Colorable):
# Number of frames to skip when reporting tracebacks
tb_offset = 0

def __init__(self, color_scheme='NoColor', call_pdb=False, ostream=None, parent=None, config=None):
def __init__(
self,
color_scheme="NoColor",
call_pdb=False,
ostream=None,
parent=None,
config=None,
*,
debugger_cls=None,
):
# Whether to call the interactive pdb debugger after printing
# tracebacks or not
super(TBTools, self).__init__(parent=parent, config=config)
Expand All @@ -227,9 +236,10 @@ def __init__(self, color_scheme='NoColor', call_pdb=False, ostream=None, parent=

self.set_colors(color_scheme)
self.old_scheme = color_scheme # save initial value for toggles
self.debugger_cls = debugger_cls or debugger.Pdb

if call_pdb:
self.pdb = debugger.Pdb()
self.pdb = debugger_cls()
else:
self.pdb = None

Expand Down Expand Up @@ -628,8 +638,15 @@ def __init__(
tb_offset=1 allows use of this handler in interpreters which will have
their own code at the top of the traceback (VerboseTB will first
remove that frame before printing the traceback info)."""
TBTools.__init__(self, color_scheme=color_scheme, call_pdb=call_pdb,
ostream=ostream, parent=parent, config=config)
TBTools.__init__(
self,
color_scheme=color_scheme,
call_pdb=call_pdb,
ostream=ostream,
parent=parent,
config=config,
debugger_cls=debugger_cls,
)
self.tb_offset = tb_offset
self.long_header = long_header
self.include_vars = include_vars
Expand All @@ -642,7 +659,6 @@ def __init__(
check_cache = linecache.checkcache
self.check_cache = check_cache

self.debugger_cls = debugger_cls or debugger.Pdb
self.skip_hidden = True

def format_record(self, frame_info):
Expand Down Expand Up @@ -907,7 +923,7 @@ def debugger(self, force: bool = False):
fix that by hand after invoking the exception handler."""

if force or self.call_pdb:
if self.debugger_cls:
if self.pdb is None:
self.pdb = self.debugger_cls()
# the system displayhook may have changed, restore the original
# for pdb
Expand Down

0 comments on commit 43fd878

Please sign in to comment.