Skip to content

gh-55646: Do not crash IDLE on an invalid key binding#152747

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-55646-invalid-keybinding-crash
Open

gh-55646: Do not crash IDLE on an invalid key binding#152747
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-55646-invalid-keybinding-crash

Conversation

@serhiy-storchaka

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

Copy link
Copy Markdown
Member

A typo in a custom key binding entered via Advanced Key Binding (which is not validated), such as <Alt-Key-up> instead of <Alt-Key-Up>, crashed IDLE at startup:

  File ".../idlelib/multicall.py", line ..., in bind
    self.__binders[triplet[1]].bind(triplet, func)
  ...
_tkinter.TclError: bad event type or keysym "up"

MultiCall.event_add stores the parsed sequence without validating the keysym, so the TclError is raised later, when a virtual event is bound and MultiCall performs the actual Tk bind. With no window yet, IDLE just exits.

Catch TclError at both binder call sites (MultiCall.bind and MultiCall.event_add) and ignore the invalid binding with a warning naming it. The bind path also drops the bad sequence from the virtual event, which avoids a secondary ValueError if it is later rebound or unbound.

🤖 Generated with Claude Code

A typo in a key binding, such as <Alt-Key-up> for <Alt-Key-Up>, crashed IDLE
at startup.  It is now ignored with a warning.
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant