Skip to content

Commit b0a0405

Browse files
[3.14] gh-152373: Make pdb "until" step over a list comprehension with a breakpoint (GH-152374) (#159958)
gh-152373: Make pdb "until" step over a list comprehension with a breakpoint (GH-152374) (cherry picked from commit 7436707) Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
1 parent bff122b commit b0a0405

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
@@ -581,7 +581,8 @@ def set_until(self, frame, lineno=None):
581581
# the name "until" is borrowed from gdb
582582
if lineno is None:
583583
lineno = frame.f_lineno + 1
584-
self._set_stopinfo(frame, frame, lineno)
584+
self._set_stopinfo(frame, frame, lineno,
585+
cmdframe=frame, cmdlineno=frame.f_lineno)
585586

586587
def set_step(self):
587588
"""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
@@ -3263,6 +3263,35 @@ def test_pdb_issue_gh_136057():
32633263
"""
32643264

32653265

3266+
def test_pdb_until_skip_comprehension():
3267+
"""See GH-152373
3268+
"until" should get over a list comprehension with a breakpoint set on it
3269+
>>> def test_function():
3270+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
3271+
... lst = [i for i in range(10)]
3272+
... for i in lst: pass
3273+
3274+
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
3275+
... 'break 3',
3276+
... 'continue',
3277+
... 'until',
3278+
... 'continue',
3279+
... ]):
3280+
... test_function()
3281+
> <doctest test.test_pdb.test_pdb_until_skip_comprehension[0]>(2)test_function()
3282+
-> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
3283+
(Pdb) break 3
3284+
Breakpoint 1 at <doctest test.test_pdb.test_pdb_until_skip_comprehension[0]>:3
3285+
(Pdb) continue
3286+
> <doctest test.test_pdb.test_pdb_until_skip_comprehension[0]>(3)test_function()
3287+
-> lst = [i for i in range(10)]
3288+
(Pdb) until
3289+
> <doctest test.test_pdb.test_pdb_until_skip_comprehension[0]>(4)test_function()
3290+
-> for i in lst: pass
3291+
(Pdb) continue
3292+
"""
3293+
3294+
32663295
def test_pdb_issue_gh_80731():
32673296
"""See GH-80731
32683297
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)