classification
Title: IDLE crash on startup with typo in config-keys.cfg
Type: behavior Stage: needs patch
Components: IDLE, Tkinter Versions: Python 3.3, Python 3.2, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: George.Dhoore, ned.deily, serwy, terry.reedy
Priority: normal Keywords: patch

Created on 2011-03-08 00:13 by George.Dhoore, last changed 2012-01-28 20:48 by serwy.

Files
File name Uploaded Description Edit
config-keys.cfg George.Dhoore, 2011-03-08 00:13 File that crashes IDLE in interpreter mode
issue11437.patch serwy, 2012-01-28 20:48 review
Messages (5)
msg130301 - (view) Author: George Dhoore (George.Dhoore) Date: 2011-03-08 00:13
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_shell
    self.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 bind
    self.__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 bind
    return self._bind(('bind', self._w), sequence, func, add)
  File "C:\Python32\Lib\tkinter\__init__.py", line 932, in _bind
    self.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.
msg130387 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-03-09 00:07
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?
msg151993 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-01-26 04:27
#13864 is a duplicate, where I mentioned the remedy of deleting the bad file.

This is similar to #5707, but I am not sure if exactly the same.
The patch there fixed one problem but not the bad key binding problem.
msg151994 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-01-26 04:33
#13071 is another duplicate closed in favor of this.
msg152187 - (view) Author: Roger Serwy (serwy) * Date: 2012-01-28 20:48
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.
History
Date User Action Args
2012-01-28 20:48:34serwysetfiles: + issue11437.patch
keywords: + patch
messages: + msg152187
2012-01-26 04:39:54terry.reedylinkissue13864 superseder
2012-01-26 04:35:35terry.reedylinkissue13071 superseder
2012-01-26 04:33:22terry.reedysetmessages: + msg151994
2012-01-26 04:27:24terry.reedysetnosy: + serwy

messages: + msg151993
versions: - Python 3.1
2011-03-09 00:07:40terry.reedysetnosy: + terry.reedy
messages: + msg130387
2011-03-08 01:48:15ned.deilysetnosy: + ned.deily
stage: needs patch
type: crash -> behavior

versions: + Python 3.1, Python 2.7, Python 3.3
2011-03-08 00:13:57George.Dhoorecreate