diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2024-05-13 12:38:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-13 12:38:21 (GMT) |
commit | f526314194f7fd15931025f8a4439c1765666e42 (patch) | |
tree | dee5cc46602bc9ba549eac269734c4bcae0c4eca /Lib/bdb.py | |
parent | d8a82cca12e12a6b22bfe6691e9b222f6d276f0a (diff) | |
download | cpython-f526314194f7fd15931025f8a4439c1765666e42.zip cpython-f526314194f7fd15931025f8a4439c1765666e42.tar.gz cpython-f526314194f7fd15931025f8a4439c1765666e42.tar.bz2 |
gh-58933: Make pdb return to caller frame correctly when f_trace is not set (#118979)
Diffstat (limited to 'Lib/bdb.py')
-rw-r--r-- | Lib/bdb.py | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -165,6 +165,11 @@ class Bdb: # The user issued a 'next' or 'until' command. if self.stopframe is frame and self.stoplineno != -1: self._set_stopinfo(None, None) + # The previous frame might not have f_trace set, unless we are + # issuing a command that does not expect to stop, we should set + # f_trace + if self.stoplineno != -1: + self._set_caller_tracefunc(frame) return self.trace_dispatch def dispatch_exception(self, frame, arg): @@ -320,15 +325,14 @@ class Bdb: self.stoplineno = stoplineno self._set_trace_opcodes(opcode) - def _set_caller_tracefunc(self): + def _set_caller_tracefunc(self, current_frame): # Issue #13183: pdb skips frames after hitting a breakpoint and running # step commands. # Restore the trace function in the caller (that may not have been set # for performance reasons) when returning from the current frame. - if self.frame_returning: - caller_frame = self.frame_returning.f_back - if caller_frame and not caller_frame.f_trace: - caller_frame.f_trace = self.trace_dispatch + caller_frame = current_frame.f_back + if caller_frame and not caller_frame.f_trace: + caller_frame.f_trace = self.trace_dispatch # Derived classes and clients can call the following methods # to affect the stepping state. @@ -343,12 +347,10 @@ class Bdb: def set_step(self): """Stop after one line of code.""" - self._set_caller_tracefunc() self._set_stopinfo(None, None) def set_stepinstr(self): """Stop before the next instruction.""" - self._set_caller_tracefunc() self._set_stopinfo(None, None, opcode=True) def set_next(self, frame): |