gh-58933: Make pdb return to caller frame correctly when f_trace is not set by gaogaotiantian · Pull Request #118979 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Lib/bdb.py
52 changes: 52 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1453,6 +1453,58 @@ def test_post_mortem():
"""


def test_pdb_return_to_different_file():
"""When pdb returns to a different file, it should not skip if f_trace is
not already set

>>> import pprint

>>> class A:
... def __repr__(self):
... return 'A'

>>> def test_function():
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
... pprint.pprint(A())

>>> reset_Breakpoint()
>>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
... 'b A.__repr__',
... 'continue',
... 'return',
... 'next',
... 'return',
... 'return',
... 'continue',
... ]):
... test_function()
> <doctest test.test_pdb.test_pdb_return_to_different_file[2]>(2)test_function()
-> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
(Pdb) b A.__repr__
Breakpoint 1 at <doctest test.test_pdb.test_pdb_return_to_different_file[1]>:3
(Pdb) continue
> <doctest test.test_pdb.test_pdb_return_to_different_file[1]>(3)__repr__()
-> return 'A'
(Pdb) return
--Return--
> <doctest test.test_pdb.test_pdb_return_to_different_file[1]>(3)__repr__()->'A'
-> return 'A'
(Pdb) next
> ...pprint.py..._safe_repr()
-> return rep,...
(Pdb) return
--Return--
> ...pprint.py..._safe_repr()->('A'...)
-> return rep,...
(Pdb) return
--Return--
> ...pprint.py...format()->('A'...)
-> return...
(Pdb) continue
A
"""


def test_pdb_skip_modules():
"""This illustrates the simple case of module skipping.

Expand Down