diff --git a/Lib/bdb.py b/Lib/bdb.py index dacbcc0a478..8f808cc4eb7 100644 --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -178,9 +178,13 @@ class Bdb: self.returnframe = frame self.quitting = 0 - def set_trace(self): - """Start debugging from here.""" - frame = sys._getframe().f_back + def set_trace(self, frame=None): + """Start debugging from `frame`. + + If frame is not specified, debugging starts from caller's frame. + """ + if frame is None: + frame = sys._getframe().f_back self.reset() while frame: frame.f_trace = self.trace_dispatch diff --git a/Lib/pdb.py b/Lib/pdb.py index b608adf2d4d..7b5dffa3b64 100755 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -997,7 +997,7 @@ def runcall(*args, **kwds): return Pdb().runcall(*args, **kwds) def set_trace(): - Pdb().set_trace() + Pdb().set_trace(sys._getframe().f_back) # Post-Mortem interface