gh-136057: Allow step and next to step over for loops #136160
+48
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Due to historical reasons,
sys.settrace
issues a line event forfor
loops even if the jump target is on the same line:We don't want to touch this behavior, because it's been like this for like forever.
However, it's not desirable to
pdb
. When the user doesnext
orstep
command, they want to step over this line and reach the next line.Our documentation also clearly states such behavior:
So I consider the current behavior as a bug, which we should fix.
A thought might be - why don't we check this in
stop_here
? The reason is becausedispatch_exception
also usesstop_here
and we should triggeruser_exception
even if it's on the same line.An extra check in
dispatch_line
is the cleanest way I can think of to make this happen - only line events should be dealt with. We don't need to worry about the extra reference to a frame because the eventualcontinue
(or anything other thanstep
ornext
) will clear this reference.Let me know if anyone has a better idea of how to implement this.