Skip to content

gh-149015: Fix iterate-and-delete issue in Bdb.clear_all_file_breaks - #149843

Closed
Godzilaa wants to merge 2 commits into
python:mainfrom
Godzilaa:fix/bdb-clear-all-file-breaks
Closed

Godzilaa wants to merge 2 commits into
python:mainfrom
Godzilaa:fix/bdb-clear-all-file-breaks

Conversation

@Godzilaa

@Godzilaa Godzilaa commented May 14, 2026 •

Copy link
Copy Markdown

Summary

When multiple breakpoints share the same line, iterating over blist while
calling bp.deleteMe() (which mutates blist) causes alternate elements
to be skipped, leaving orphan breakpoints.

This is a one-character fix: add [:] to create a copy before iterating,
matching the existing defensive pattern in clear_break() at line 722.

The Bug

# Before fix (line 750):
for bp in blist:           # iterating raw list
    bp.deleteMe()          # mutates blist - skips alternate elements!
# After fix (line 750):
for bp in blist[:]:        # iterating a copy
    bp.deleteMe()          # safe - original list untouched

Example

For N breakpoints at the same (file, line), floor(N/2) orphans remain
in Breakpoint.bplist and Breakpoint.bpbynumber.

Testing

This follows the same pattern already used in clear_break() at line 722,
which was confirmed working by the maintainers.

See issue #149015 for more details.

…reaks

When multiple breakpoints share the same line, iterating over blist while
calling bp.deleteMe() (which mutates blist) causes alternate elements to
be skipped, leaving orphan breakpoints.

This is a one-character fix: add [:] to create a copy before iterating,
matching the existing defensive pattern in clear_break() at line 722.
@Godzilaa
Godzilaa requested a review from gaogaotiantian as a code owner May 14, 2026 18:21
@bedevere-app

bedevere-app Bot commented May 14, 2026

Copy link
Copy Markdown

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 skip news label instead.

@python-cla-bot

python-cla-bot Bot commented May 14, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented May 17, 2026

Copy link
Copy Markdown

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 skip news label instead.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants