Skip to content

Commit 7436707

Browse files
authored
gh-152373: Make pdb "until" step over a list comprehension with a breakpoint (#152374)
1 parent 2648604 commit 7436707

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

‎Lib/bdb.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,8 @@ def set_until(self, frame, lineno=None):
572572
# the name "until" is borrowed from gdb
573573
if lineno is None:
574574
lineno = frame.f_lineno + 1
575-
self._set_stopinfo(frame, frame, lineno)
575+
self._set_stopinfo(frame, frame, lineno,
576+
cmdframe=frame, cmdlineno=frame.f_lineno)
576577

577578
def set_step(self):
578579
"""Stop after one line of code."""

‎Lib/test/test_pdb.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,6 +3264,35 @@ def test_pdb_issue_gh_136057():
32643264
"""
32653265

32663266

3267+
def test_pdb_until_skip_comprehension():
3268+
"""See GH-152373
3269+
"until" should get over a list comprehension with a breakpoint set on it
3270+
>>> def test_function():
3271+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
3272+
... lst = [i for i in range(10)]
3273+
... for i in lst: pass
3274+
3275+
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
3276+
... 'break 3',
3277+
... 'continue',
3278+
... 'until',
3279+
... 'continue',
3280+
... ]):
3281+
... test_function()
3282+
> <doctest test.test_pdb.test_pdb_until_skip_comprehension[0]>(2)test_function()
3283+
-> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
3284+
(Pdb) break 3
3285+
Breakpoint 1 at <doctest test.test_pdb.test_pdb_until_skip_comprehension[0]>:3
3286+
(Pdb) continue
3287+
> <doctest test.test_pdb.test_pdb_until_skip_comprehension[0]>(3)test_function()
3288+
-> lst = [i for i in range(10)]
3289+
(Pdb) until
3290+
> <doctest test.test_pdb.test_pdb_until_skip_comprehension[0]>(4)test_function()
3291+
-> for i in lst: pass
3292+
(Pdb) continue
3293+
"""
3294+
3295+
32673296
def test_pdb_issue_gh_80731():
32683297
"""See GH-80731
32693298
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix the :mod:`pdb` ``until`` command not stepping over a list comprehension
2+
when a breakpoint is set on it. Patch by tonghuaroot.

0 commit comments

Comments
 (0)