You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pdb: 'n' and 'until' do not skip list comprehension after setting a breakpoint #136057
When debugging in Python using pdb, I set a breakpoint at a line with a list comprehension. However, when I use n or until, the debugger steps into the list comprehension multiple times (equal to its iteration count), rather than skipping to the next line. This behavior is unexpected and inconsistent with how n is supposed to work.
When it breaks at line 6 (population = [...]), type:
n
until
until 8
It does not proceed to line 8 (the next executable line), but instead steps into the list comprehension 10 times.
Expected Behavior:
After hitting the breakpoint, using n or until should step over the entire list comprehension expression and proceed to the next line of code (for generation in range(10): in this case), not into each iteration of the list comprehension.
Actual Behavior:
The debugger enters the list comprehension and steps through each iteration, behaving as if the list comprehension is an expanded for-loop.
Environment:
Python Version: 3.12.2
Platform: Windows 11
IDE: Visual Studio Code
Execution: Running via terminal/debug console with built-in pdb
Activity
LamentXU123 commentedon Jun 28, 2025
LGTM, cc @gaogaotiantian
gaogaotiantian commentedon Jun 28, 2025
Thanks for the detailed explanation. Next time you can make the example shorter :) Just to get to the actual problem. I'll take a look into it.
gh-136057: Allow step and next to step over for loops (#136160)
pythongh-136057: Allow step and next to step over for loops (pythonGH…
[3.14] gh-136057: Allow step and next to step over for loops (GH-136160…
[3.13] gh-136057: Allow step and next to step over for loops (GH-136160…
picnixz commentedon Nov 16, 2025
Thanks for the report @lixiaoyaol and for the fix Tian!
pythongh-136057: Allow step and next to step over for loops (python#1…