You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IDLE crash on startup with typo in config-keys.cfg #55646
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/terryjreedy'closed_at=Nonecreated_at=<Date2011-03-08.00:13:57.851>labels= ['3.7', 'expert-IDLE', 'type-bug', 'expert-tkinter']
title='IDLE crash on startup with typo in config-keys.cfg'updated_at=<Date2017-09-28.06:58:52.142>user='https://bugs.python.org/GeorgeDhoore'
If the user makes a typo when setting a custom keybind (in this case "<Alt-Key-up>" instead of "<Alt-Key-Up>") IDLE will silently crash. From the command-line the error shows as:
Traceback (most recent call last):
File "C:\Python32\Lib\idlelib\idle.py", line 11, in <module>
idlelib.PyShell.main()
File "C:\Python32\Lib\idlelib\PyShell.py", line 1388, in main
shell = flist.open_shell()
File "C:\Python32\Lib\idlelib\PyShell.py", line 277, in open_shellself.pyshell = PyShell(self)
File "C:\Python32\Lib\idlelib\PyShell.py", line 856, in __init__self.history =self.History(self.text)
File "C:\Python32\Lib\idlelib\IdleHistory.py", line 12, in __init__
text.bind("<<history-previous>>", self.history_prev)
File "C:\Python32\Lib\idlelib\MultiCall.py", line 332, in bindself.__binders[triplet[1]].bind(triplet, func)
File "C:\Python32\Lib\idlelib\MultiCall.py", line 213, in bind
seq, handler)))
File "C:\Python32\Lib\tkinter\__init__.py", line 977, in bindreturnself._bind(('bind', self._w), sequence, func, add)
File "C:\Python32\Lib\tkinter\__init__.py", line 932, in _bindself.tk.call(what + (sequence, cmd))
_tkinter.TclError: bad event type or keysym "up"
This is doubly confusing as case sensitivity seems to be applied at random in config-keys.cfg.
Expected behavior:
Ideally case sensitivity shouldn't matter in config-keys.cfg and if there is an error in the config syntax, that particular line should be ignored and the rest of the file tried. If IDLE is still able to start, some user friendly error should be displayed indicating the problem line.
I presume 'silently' means when starting with an icon or shortcut, so that there is no window left to contain the traceback.
The standard key customization is by clicking, which makes errors impossible. How did you get the error? By using the "Advanced Key Binding Entry" button, which warns "These bindings will not be checked for validity!"? Or by directly editing the a file in its undocumented location (which is unknown to me)? [Question: why is either alternative
needed?]
Case sensitivity is a feature of string comparison. In this case, it is done by tcl and beyond our control. Adding validity checking where now disclaimed would be a possible feature request.
Assuming the binding is done within a loop, it would be reasonable to wrap the failing call with try...except TclError: display message "When binding key '...' to action '...', tcl reports error <emsg>".
bpo-13071 is another duplicate closed in favor of this.
serwy commented on Jan 28, 2012
serwymannequin
Mannequin
More actions
Attached is a patch against 3.3a0 to validate the active key set in the configuration handler. It validates each key binding and then presents a dialog with a list of incorrect keys if there are any.
In developing this patch I found that IDLE calls GetCurrentKeySet multiple times during initialization of an EditorWindow or a PyShell, once for each extension loaded. This inefficiency leads to long start times for IDLE.
What steps should I do to reproduce the issue? Pushing config from George.Dhoore into ~/.idlerc does nothing. IDLE starts fine as usual.
serwy commented on Mar 29, 2012
serwymannequin
Mannequin
More actions
Andrew, after placing config-keys.cfg into .idlerc, launch IDLE and change the key map to Xip's keyset. You'll get a traceback on the terminal when you click ok.
Roger Serwy, your patch looks working, but can you describe:
Why do you need self.known_invalid list?
Why do you always extend that list (known_invalid variable is
just shared alias for self.known_invalid member, not list copy).
I'm a bit confusing with that logic.
serwy commented on Mar 31, 2012
serwymannequin
Mannequin
More actions
Without the known_invalid list, each call to GetCurrentKeySet would cause an error message to appear. The effect of keeping track of these bad key bindings is that the user receives a notification only once about a particular bad key binding. (The present architecture in IDLE calls GetCurrentKeySet too many times during initialization.)
The known_invalid list gets extended with any newly found invalid key bindings. Also, these newly found invalid keys generates an error message. This can occur again if the user modifies the key map with the configuration dialog.
Perhaps using a set instead of a list would make the code clearer.
Activity
GeorgeDhoore commentedon Mar 8, 2011
If the user makes a typo when setting a custom keybind (in this case "<Alt-Key-up>" instead of "<Alt-Key-Up>") IDLE will silently crash. From the command-line the error shows as:
This is doubly confusing as case sensitivity seems to be applied at random in config-keys.cfg.
Expected behavior:
Ideally case sensitivity shouldn't matter in config-keys.cfg and if there is an error in the config syntax, that particular line should be ignored and the rest of the file tried. If IDLE is still able to start, some user friendly error should be displayed indicating the problem line.
terryjreedy commentedon Mar 9, 2011
I presume 'silently' means when starting with an icon or shortcut, so that there is no window left to contain the traceback.
The standard key customization is by clicking, which makes errors impossible. How did you get the error? By using the "Advanced Key Binding Entry" button, which warns "These bindings will not be checked for validity!"? Or by directly editing the a file in its undocumented location (which is unknown to me)? [Question: why is either alternative
needed?]
Case sensitivity is a feature of string comparison. In this case, it is done by tcl and beyond our control. Adding validity checking where now disclaimed would be a possible feature request.
Assuming the binding is done within a loop, it would be reasonable to wrap the failing call with try...except TclError: display message "When binding key '...' to action '...', tcl reports error <emsg>".
Can you submit a patch?
terryjreedy commentedon Jan 26, 2012
bpo-13864 is a duplicate, where I mentioned the remedy of deleting the bad file.
This is similar to bpo-5707, but I am not sure if exactly the same.
The patch there fixed one problem but not the bad key binding problem.
terryjreedy commentedon Jan 26, 2012
bpo-13071 is another duplicate closed in favor of this.
serwy commentedon Jan 28, 2012
Attached is a patch against 3.3a0 to validate the active key set in the configuration handler. It validates each key binding and then presents a dialog with a list of incorrect keys if there are any.
In developing this patch I found that IDLE calls GetCurrentKeySet multiple times during initialization of an EditorWindow or a PyShell, once for each extension loaded. This inefficiency leads to long start times for IDLE.
asvetlov commentedon Mar 29, 2012
Roger, can you help me?
What steps should I do to reproduce the issue? Pushing config from George.Dhoore into ~/.idlerc does nothing. IDLE starts fine as usual.
serwy commentedon Mar 29, 2012
Andrew, after placing config-keys.cfg into .idlerc, launch IDLE and change the key map to Xip's keyset. You'll get a traceback on the terminal when you click ok.
asvetlov commentedon Mar 31, 2012
I reproduced the bug.
Roger Serwy, your patch looks working, but can you describe:
self.known_invalidlist?known_invalidvariable isjust shared alias for
self.known_invalidmember, not list copy).I'm a bit confusing with that logic.
serwy commentedon Mar 31, 2012
Without the known_invalid list, each call to GetCurrentKeySet would cause an error message to appear. The effect of keeping track of these bad key bindings is that the user receives a notification only once about a particular bad key binding. (The present architecture in IDLE calls GetCurrentKeySet too many times during initialization.)
The known_invalid list gets extended with any newly found invalid key bindings. Also, these newly found invalid keys generates an error message. This can occur again if the user modifies the key map with the configuration dialog.
Perhaps using a set instead of a list would make the code clearer.
13 remaining items
pythongh-55646: Fix the invalid key binding test on macOS
Merge branch 'main' into pythongh-55646-invalid-keybinding-crash
pythongh-55646: Name the action and suggest reconfiguring in the warning
pythongh-55646: Rename warn_bad_binding to a non-underscored name
gh-55646: Do not crash IDLE on an invalid key binding (#152747)
[3.14] gh-55646: Do not crash IDLE on an invalid key binding (GH-152747…
[3.13] gh-55646: Do not crash IDLE on an invalid key binding (GH-152747…
[3.15] gh-55646: Do not crash IDLE on an invalid key binding (GH-152747…