mirror of https://github.com/python/cpython
gh-80675: Set `f_trace_lines = True` on all frames upon `pdb.set_trace()` (#110881)
This commit is contained in:
parent
9573d14215
commit
cd6b2ced75
|
@ -32,6 +32,7 @@ class Bdb:
|
|||
self.skip = set(skip) if skip else None
|
||||
self.breaks = {}
|
||||
self.fncache = {}
|
||||
self.frame_trace_lines = {}
|
||||
self.frame_returning = None
|
||||
|
||||
self._load_breaks()
|
||||
|
@ -331,6 +332,9 @@ class Bdb:
|
|||
while frame:
|
||||
frame.f_trace = self.trace_dispatch
|
||||
self.botframe = frame
|
||||
# We need f_trace_liens == True for the debugger to work
|
||||
self.frame_trace_lines[frame] = frame.f_trace_lines
|
||||
frame.f_trace_lines = True
|
||||
frame = frame.f_back
|
||||
self.set_step()
|
||||
sys.settrace(self.trace_dispatch)
|
||||
|
@ -349,6 +353,9 @@ class Bdb:
|
|||
while frame and frame is not self.botframe:
|
||||
del frame.f_trace
|
||||
frame = frame.f_back
|
||||
for frame, prev_trace_lines in self.frame_trace_lines.items():
|
||||
frame.f_trace_lines = prev_trace_lines
|
||||
self.frame_trace_lines = {}
|
||||
|
||||
def set_quit(self):
|
||||
"""Set quitting attribute to True.
|
||||
|
|
|
@ -2350,6 +2350,30 @@ def test_pdb_ambiguous_statements():
|
|||
(Pdb) continue
|
||||
"""
|
||||
|
||||
def test_pdb_f_trace_lines():
|
||||
"""GH-80675
|
||||
|
||||
pdb should work even if f_trace_lines is set to False on some frames.
|
||||
|
||||
>>> reset_Breakpoint()
|
||||
|
||||
>>> def test_function():
|
||||
... import sys
|
||||
... frame = sys._getframe()
|
||||
... frame.f_trace_lines = False
|
||||
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
|
||||
... if frame.f_trace_lines != False:
|
||||
... print("f_trace_lines is not reset after continue!")
|
||||
|
||||
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
|
||||
... 'continue'
|
||||
... ]):
|
||||
... test_function()
|
||||
> <doctest test.test_pdb.test_pdb_f_trace_lines[1]>(6)test_function()
|
||||
-> if frame.f_trace_lines != False:
|
||||
(Pdb) continue
|
||||
"""
|
||||
|
||||
def test_pdb_function_break():
|
||||
"""Testing the line number of break on function
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Set ``f_trace_lines = True`` on all frames upon :func:`pdb.set_trace()`
|
Loading…
Reference in New Issue