Skip to content

Commit 313a751

Browse files
committed
This is a Python 2.1 and 2.2 bugfix candidate:
(or how do I "mark" something to be a candidate?) fixed an old buglet that caused bdb to be unable to continue in the botframe, after a breakpoint was set. the key idea is not to set botframe to the bottom level frame, but its f_back, which actually might be None. Additional changes: migrated old exception trick to use sys._getframe(), which exists both in 2.1 and 2.2 . Note: I believe Mark Hammond needs to look over his code now. F5 correctly starts up in the debugger, but later on doesn't stop at a given breakpoint any longer. kind regards - chris
1 parent 72de9c7 commit 313a751

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Lib/bdb.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def dispatch_call(self, frame, arg):
6565
# XXX 'arg' is no longer used
6666
if self.botframe is None:
6767
# First call of dispatch since reset()
68-
self.botframe = frame
68+
self.botframe = frame.f_back # (CT) Note that this may also be None!
6969
return self.trace_dispatch
7070
if not (self.stop_here(frame) or self.break_anywhere(frame)):
7171
# No need to trace this function
@@ -91,8 +91,8 @@ def dispatch_exception(self, frame, arg):
9191
# definition of stopping and breakpoints.
9292

9393
def stop_here(self, frame):
94-
if self.stopframe is None:
95-
return True
94+
# (CT) stopframe may now also be None, see dispatch_call.
95+
# (CT) the former test for None is therefore removed from here.
9696
if frame is self.stopframe:
9797
return True
9898
while frame is not None and frame is not self.stopframe:
@@ -169,10 +169,7 @@ def set_return(self, frame):
169169

170170
def set_trace(self):
171171
"""Start debugging from here."""
172-
try:
173-
raise Exception
174-
except:
175-
frame = sys.exc_info()[2].tb_frame.f_back
172+
frame = sys._getframe().f_back
176173
self.reset()
177174
while frame:
178175
frame.f_trace = self.trace_dispatch
@@ -189,10 +186,7 @@ def set_continue(self):
189186
if not self.breaks:
190187
# no breakpoints; run without debugger overhead
191188
sys.settrace(None)
192-
try:
193-
raise Exception
194-
except:
195-
frame = sys.exc_info()[2].tb_frame.f_back
189+
frame = sys._getframe().f_back
196190
while frame and frame is not self.botframe:
197191
del frame.f_trace
198192
frame = frame.f_back

0 commit comments

Comments
 (0)