python / python/cpython

pdb: "until" does not step over a list comprehension with a breakpoint set on it

Open
#152,373 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

When a breakpoint is set on a line that holds a list comprehension (or any
single-line loop), the until command stops on that same line again on every
iteration instead of moving past it.

Reproduction:

# repro.py
def f():
    lst = [i for i in range(10)]
    for i in lst: pass

f()
$ python -m pdb repro.py
> repro.py(1)<module>()
-> def f():
(Pdb) break 2
Breakpoint 1 at repro.py:2
(Pdb) continue
> repro.py(2)f()
-> lst = [i for i in range(10)]
(Pdb) until
> repro.py(2)f()
-> lst = [i for i in range(10)]
(Pdb) until
> repro.py(2)f()
-> lst = [i for i in range(10)]

until keeps stopping on line 2, once per comprehension element.

Expected: until moves past the comprehension to the next line, the way next
and step already do (gh-136057, gh-136160). This also matches gdb, which
pdb's until is borrowed from: there, until steps past a single-line loop
to the next line even with a breakpoint set on it, instead of stopping on each
iteration.

I have a small fix for this and can open a PR.

Linked PRs
  • gh-152374

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the pdb entry point and reproduce the behavior using repro.py, setting a breakpoint on the list-comprehension line and running until repeatedly. Compare until with next and step as described in the issue. Done means until advances to the next line rather than stopping on each comprehension element; a linked PR is already recorded.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.