Skip to content
Closed
Changes from all commits
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
7 changes: 5 additions & 2 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,9 @@ def do_debug(self, arg):
argument (which is an arbitrary expression or statement to be
executed in the current environment).
"""
sys.settrace(None)
orig_trace = sys.gettrace()
if orig_trace:
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe_locals
p = Pdb(self.completekey, self.stdin, self.stdout)
Expand All @@ -1106,7 +1108,8 @@ def do_debug(self, arg):
exc_info = sys.exc_info()[:2]
self.error(traceback.format_exception_only(*exc_info)[-1].strip())
self.message("LEAVING RECURSIVE DEBUGGER")
sys.settrace(self.trace_dispatch)
if orig_trace:
sys.settrace(orig_trace)
self.lastcmd = p.lastcmd

complete_debug = _complete_expression
Expand Down