Skip to content

gh-89360: Fix ValueError in IDLE MultiCall event_delete#152738

Merged
terryjreedy merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-89360-multicall-event-delete
Jul 1, 2026
Merged

gh-89360: Fix ValueError in IDLE MultiCall event_delete#152738
terryjreedy merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-89360-multicall-event-delete

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 1, 2026

Copy link
Copy Markdown
Member

MultiCall.event_delete() called triplets.remove(triplet) unconditionally. When the sequence was not actually bound to the virtual event — a rare discrepancy that could happen when the completion window was closed — this raised ValueError: list.remove(x): x not in list, crashing through the Tk callback (reported by @rhettinger).

The unbind and remove are now skipped when the sequence is not bound. This is safer than catching only triplets.remove(), because the binder's unbind() also does bindedfuncs.remove(func), which would raise ValueError as well. event_add() pairs the bind and append, so the membership check keeps both structures consistent.

The added test reproduces the exact scenario (add one sequence, delete a different one); it raises the reported ValueError without the fix.

🤖 Generated with Claude Code

Deleting a key binding for a sequence not bound to the virtual event no
longer raises a ValueError; the discrepancy is now ignored.
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 1, 2026
@terryjreedy terryjreedy merged commit ea7619f into python:main Jul 1, 2026
59 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 1, 2026

Copy link
Copy Markdown

GH-152802 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 1, 2026
@bedevere-app

bedevere-app Bot commented Jul 1, 2026

Copy link
Copy Markdown

GH-152803 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 1, 2026
@bedevere-app

bedevere-app Bot commented Jul 1, 2026

Copy link
Copy Markdown

GH-152804 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jul 1, 2026
@serhiy-storchaka serhiy-storchaka deleted the gh-89360-multicall-event-delete branch July 1, 2026 16:47
terryjreedy pushed a commit that referenced this pull request Jul 1, 2026
…2738) (#152804)

gh-89360: Fix ValueError in IDLE MultiCall event_delete (GH-152738)

Deleting a key binding for a sequence not bound to the virtual event no
longer raises a ValueError; the discrepancy is now ignored.
(cherry picked from commit ea7619f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
terryjreedy pushed a commit that referenced this pull request Jul 1, 2026
…2738) (#152803)

gh-89360: Fix ValueError in IDLE MultiCall event_delete (GH-152738)

Deleting a key binding for a sequence not bound to the virtual event no
longer raises a ValueError; the discrepancy is now ignored.
(cherry picked from commit ea7619f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
terryjreedy pushed a commit that referenced this pull request Jul 1, 2026
…2738) (#152802)

gh-89360: Fix ValueError in IDLE MultiCall event_delete (GH-152738)

Deleting a key binding for a sequence not bound to the virtual event no
longer raises a ValueError; the discrepancy is now ignored.
(cherry picked from commit ea7619f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants