diff --git a/Lib/bdb.py b/Lib/bdb.py index 50cf2b3f5b3e453..7794a4606697cd7 100644 --- a/Lib/bdb.py +++ b/Lib/bdb.py @@ -572,7 +572,8 @@ def set_until(self, frame, lineno=None): # the name "until" is borrowed from gdb if lineno is None: lineno = frame.f_lineno + 1 - self._set_stopinfo(frame, frame, lineno) + self._set_stopinfo(frame, frame, lineno, + cmdframe=frame, cmdlineno=frame.f_lineno) def set_step(self): """Stop after one line of code.""" diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 0cf5dd2e4c10042..2f26ce8aae959a1 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -3264,6 +3264,35 @@ def test_pdb_issue_gh_136057(): """ +def test_pdb_until_skip_comprehension(): + """See GH-152373 + "until" should get over a list comprehension with a breakpoint set on it + >>> def test_function(): + ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + ... lst = [i for i in range(10)] + ... for i in lst: pass + + >>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE + ... 'break 3', + ... 'continue', + ... 'until', + ... 'continue', + ... ]): + ... test_function() + > (2)test_function() + -> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + (Pdb) break 3 + Breakpoint 1 at :3 + (Pdb) continue + > (3)test_function() + -> lst = [i for i in range(10)] + (Pdb) until + > (4)test_function() + -> for i in lst: pass + (Pdb) continue + """ + + def test_pdb_issue_gh_80731(): """See GH-80731 diff --git a/Misc/NEWS.d/next/Library/2026-06-27-08-31-30.gh-issue-152373.3cd0aa.rst b/Misc/NEWS.d/next/Library/2026-06-27-08-31-30.gh-issue-152373.3cd0aa.rst new file mode 100644 index 000000000000000..bf6a70c1374a0db --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-27-08-31-30.gh-issue-152373.3cd0aa.rst @@ -0,0 +1,2 @@ +Fix the :mod:`pdb` ``until`` command not stepping over a list comprehension +when a breakpoint is set on it. Patch by tonghuaroot.