gh-149015: avoid iterate-and-delete issue in Bdb.clear_all_file_breaks#149039
Open
AmSach wants to merge 2 commits intopython:mainfrom
Open
gh-149015: avoid iterate-and-delete issue in Bdb.clear_all_file_breaks#149039AmSach wants to merge 2 commits intopython:mainfrom
Bdb.clear_all_file_breaks#149039AmSach wants to merge 2 commits intopython:mainfrom
Conversation
…-delete bug (pythongh-149015) When multiple breakpoints share the same (filename, line), iterating the list directly while calling deleteMe() (which removes from the same list) causes the loop to skip alternate elements, leaving floor(N/2) orphan breakpoints. The fix (for bp in blist: → for bp in blist[:]:) matches the existing defensive pattern already used in clear_break() in the same file. Added regression test test_clear_all_file_breaks_with_multiple_bps_same_line.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Bdb.clear_all_file_breaks to avoid iterate-and-delete bug
Bdb.clear_all_file_breaks to avoid iterate-and-delete bugBdb.clear_all_file_breaks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix for gh-149015: bdb.Bdb.clear_all_file_breaks() skips breakpoints when multiple share the same (filename, line).
Root cause: iterating a list directly while deleteMe() removes items from that same list causes the loop to skip every other element. For N breakpoints at the same (file, line), floor(N/2) orphans remain.
Fix: one-character change - add slice copy to avoid mutating during iteration:
This matches the existing defensive pattern already used in clear_break() (same file, same class).
Files:
Closes #149015