Skip to content

Commit

Permalink
bdb: Re-enable usage of frame.f_trace.
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-anl committed Jun 20, 2022
1 parent edc0a66 commit c03abd8
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions python-stdlib/bdb/bdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ def dispatch_line(self, frame):
return self.trace_dispatch

def is_coroutine(self, frame):
## MPY: co_flags attrib not available, compatible method of detecting coroutine TBD
## MPY: co_flags attrib not available, compatible method of detecting coroutine TBD
# return frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS
return False


def dispatch_call(self, frame, arg):
"""Invoke user function and return trace function for call event.
Expand Down Expand Up @@ -321,9 +321,8 @@ def set_step(self):
# for performance reasons) when returning from the current frame.
if self.frame_returning:
caller_frame = self.frame_returning.f_back
## MPY: f_trace attrib not yet available
# if caller_frame and not caller_frame.f_trace:
# caller_frame.f_trace = self.trace_dispatch
if caller_frame and not caller_frame.f_trace:
caller_frame.f_trace = self.trace_dispatch
self._set_stopinfo(None, None)

def set_next(self, frame):
Expand All @@ -345,11 +344,10 @@ def set_trace(self, frame=None):
if frame is None:
frame = sys._getframe(1)
self.reset()
## MPY: f_trace attrib not yet available
# while frame:
# frame.f_trace = self.trace_dispatch
# self.botframe = frame
# frame = frame.f_back
while frame:
frame.f_trace = self.trace_dispatch
self.botframe = frame
frame = frame.f_back
self.set_step()
sys.settrace(self.trace_dispatch)

Expand All @@ -365,10 +363,9 @@ def set_continue(self):
sys.settrace(None)
## MPY: was sys._getframe().f_back but f_back missing when inside trace dispatch functions
frame = sys._getframe(1)
## MPY: f_trace attrib not yet available
# while frame and frame is not self.botframe:
# del frame.f_trace
# frame = frame.f_back
while frame and frame is not self.botframe:
del frame.f_trace
frame = frame.f_back

def set_quit(self):
"""Set quitting attribute to True.
Expand Down

0 comments on commit c03abd8

Please sign in to comment.