Skip to content

Commit c1d415b

Browse files
committed
bdb: Re-enable usage of frame.f_trace.
Requires micropython/micropython#8767
1 parent e72b066 commit c1d415b

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

python-stdlib/bdb/bdb.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ def dispatch_line(self, frame):
126126
return self.trace_dispatch
127127

128128
def is_coroutine(self, frame):
129-
## MPY: co_flags attrib not available, compatible method of detecting coroutine TBD
129+
## MPY: co_flags attrib not available, compatible method of detecting coroutine TBD
130130
# return frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS
131131
return False
132132

133-
133+
134134
def dispatch_call(self, frame, arg):
135135
"""Invoke user function and return trace function for call event.
136136
@@ -321,9 +321,8 @@ def set_step(self):
321321
# for performance reasons) when returning from the current frame.
322322
if self.frame_returning:
323323
caller_frame = self.frame_returning.f_back
324-
## MPY: f_trace attrib not yet available
325-
# if caller_frame and not caller_frame.f_trace:
326-
# caller_frame.f_trace = self.trace_dispatch
324+
if caller_frame and not caller_frame.f_trace:
325+
caller_frame.f_trace = self.trace_dispatch
327326
self._set_stopinfo(None, None)
328327

329328
def set_next(self, frame):
@@ -345,11 +344,10 @@ def set_trace(self, frame=None):
345344
if frame is None:
346345
frame = sys._getframe(1)
347346
self.reset()
348-
## MPY: f_trace attrib not yet available
349-
# while frame:
350-
# frame.f_trace = self.trace_dispatch
351-
# self.botframe = frame
352-
# frame = frame.f_back
347+
while frame:
348+
frame.f_trace = self.trace_dispatch
349+
self.botframe = frame
350+
frame = frame.f_back
353351
self.set_step()
354352
sys.settrace(self.trace_dispatch)
355353

@@ -365,10 +363,9 @@ def set_continue(self):
365363
sys.settrace(None)
366364
## MPY: was sys._getframe().f_back but f_back missing when inside trace dispatch functions
367365
frame = sys._getframe(1)
368-
## MPY: f_trace attrib not yet available
369-
# while frame and frame is not self.botframe:
370-
# del frame.f_trace
371-
# frame = frame.f_back
366+
while frame and frame is not self.botframe:
367+
del frame.f_trace
368+
frame = frame.f_back
372369

373370
def set_quit(self):
374371
"""Set quitting attribute to True.

0 commit comments

Comments
 (0)