Skip to content

Commit f7b6036

Browse files
committed
Add regression test for gh-141781
1 parent 78500dd commit f7b6036

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lib/test/test_pdb.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3567,6 +3567,7 @@ def test_find_function_empty_file(self):
35673567
def test_find_function_found(self):
35683568
self._assert_find_function(
35693569
"""\
3570+
35703571
def foo():
35713572
pass
35723573
@@ -3580,6 +3581,20 @@ def quux():
35803581
('bœr', 5),
35813582
)
35823583

3584+
def test_print_stack_entry_uses_dynamic_line_prefix(self):
3585+
"""Test that pdb.line_prefix binding is dynamic (gh-141781)."""
3586+
stdout = io.StringIO()
3587+
p = pdb.Pdb(stdout=stdout)
3588+
3589+
# Get the current frame to use for printing
3590+
frame = sys._getframe()
3591+
3592+
with support.swap_attr(pdb, 'line_prefix', 'CUSTOM_PREFIX> '):
3593+
p.print_stack_entry((frame, frame.f_lineno))
3594+
3595+
# Check if the custom prefix appeared in the output
3596+
self.assertIn('CUSTOM_PREFIX> ', stdout.getvalue())
3597+
35833598
def test_find_function_found_with_encoding_cookie(self):
35843599
self._assert_find_function(
35853600
"""\

0 commit comments

Comments
 (0)