classification
Title: IDLE: refuse invalid key bindings
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: CaribbeanCruise, amaury.forgeotdarc, csabella, gpolo, roger.serwy, terry.reedy
Priority: normal Keywords: patch

Created on 2009-08-20 08:31 by CaribbeanCruise, last changed 2017-06-26 05:38 by terry.reedy. This issue is now closed.

Files
File name Uploaded Description Edit
tcl_validation.diff gpolo, 2009-08-21 15:12
Pull Requests
URL Status Linked Edit
PR 2377 merged csabella, 2017-06-24 11:05
PR 2397 merged terry.reedy, 2017-06-26 04:59
Messages (12)
msg91762 - (view) Author: (CaribbeanCruise) Date: 2009-08-20 08:31
I tried to assign a new key(lctrl+lshift instead of lctrl+F5) for run-
mode in option in v.2.5.2. I tried the new key and it didn't work. And 
then I got lots of messages.
So I killed the IDLE and the rest of python. And run IDLE again, 
background process indicates some activity for 5secs. And then it was 
gone. No IDLE window showed up. 
So I uninstalled the 2.5.2. and installed the v.3.1.1. The installation 
process went ok, but when I starts IDLE. Nothing happens.
I tried and run idle.py in cmd, while I'm a vista user and got this:

Traceback (most recent call last):
  File "C:\Python31\Lib\idlelib\idle.py", line 11, in <module>
    idlelib.PyShell.main()
  File "C:\Python31\Lib\idlelib\PyShell.py", line 1388, in main
    shell = flist.open_shell()
  File "C:\Python31\Lib\idlelib\PyShell.py", line 277, in open_shell
    self.pyshell = PyShell(self)
  File "C:\Python31\Lib\idlelib\PyShell.py", line 813, in __init__
    OutputWindow.__init__(self, flist, None, None)
  File "C:\Python31\Lib\idlelib\OutputWindow.py", line 16, in __init__
    EditorWindow.__init__(self, *args)
  File "C:\Python31\Lib\idlelib\EditorWindow.py", line 135, in __init__
    self.apply_bindings()
  File "C:\Python31\Lib\idlelib\EditorWindow.py", line 961, in 
apply_bindings
    text.event_add(event, *keylist)
  File "C:\Python31\Lib\idlelib\MultiCall.py", line 359, in event_add
    widget.event_add(self, virtual, seq)
  File "C:\Python31\Lib\tkinter\__init__.py", line 1353, in event_add
    self.tk.call(args)
_tkinter.TclError: bad event type or keysym "Shift"

What do I do to get this up and running?
msg91812 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-08-21 09:56
- find your .idlerc directory (probably in %USERPROFILE%)
- edit config-extensions.cfg
- remove the <Control-Shift> binding

- write a patch that refuses invalid keysims.
msg91830 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-08-21 15:12
Here is a patch that changes IDLE to refuse invalid key bindings.
msg91863 - (view) Author: (CaribbeanCruise) Date: 2009-08-22 12:59
Thanks for the help.

I removed that external row and now it's up and running again :D May I 
please have an explanation on what causes that behavior and why that 
solution on that file worked?

I'm just a n00b/beginner level on programming and I will someday try to 
understand that patch, how I can write that patch and put it in place to 
make it work.

Thank you very much for the help and guidance.
msg91866 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-08-22 17:38
Please, understand that the bug tracker is a place to provide help and
not to seek for help. The c.l.p newsgroup (more on
http://www.python.org/community/lists/) is a more appropriate place to
continue this discussion.

Nevertheless, the attached patch was generated from python trunk so if
you want to apply it by hand you will need to check what file it changed
(first lines on it) and then check line offsets (@@ ... @@) to know
where to hand-apply each hunk. Applying any patch this way may cause
more trouble than anything else, be careful.
msg228301 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-10-03 03:09
#21519 also patched key validation
msg296563 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-21 15:50
I believe patch for #21519 affects area of file patched here.
msg296651 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-22 19:47
Patch mostly looks good.  To apply now, keybindingDialog.py must become config_key.py.  I have no idea what other merge issues there might be.  The name of the new function'KeySequenceCheck()' should be 'sequence_ok()'.  A minimal new test should call sequence_ok with invalid sequence '<Control-Shift>' and valid sequence '<Control-Shift-Key-x>'.
msg296765 - (view) Author: Cheryl Sabella (csabella) * Date: 2017-06-24 11:10
I've made a PR for the patch.

Even though other tests need to be added, I only added a test for the call to sequence_ok().  Testing this by itself will probably allow it to be mocked in other tests.

I also added a call to the unittest in config_key.py.
msg296845 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-26 04:55
New changeset 8c78aa70c888a370af18896a72cabd00e4120f09 by terryjreedy (csabella) in branch 'master':
bpo-6739: IDLE: Check for valid keybinding in config_keys (#2377)
https://github.com/python/cpython/commit/8c78aa70c888a370af18896a72cabd00e4120f09
msg296850 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-26 05:21
New changeset 64a0c266e78c6b5363668012fa7fb614f6018930 by terryjreedy in branch '3.6':
[3.6] bpo-6739: IDLE: Check for valid keybinding in config_keys (GH-2377) (#2397)
https://github.com/python/cpython/commit/64a0c266e78c6b5363668012fa7fb614f6018930
msg296851 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-26 05:38
Guilherme, thank you for the patch.  Sorry it took so long to be applied.  Cheryl, thank you for making the PR.  Writing invalid, exception-raising sequences to user config files was a definite bug.
History
Date User Action Args
2017-06-26 05:38:16terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg296851

stage: test needed -> resolved
2017-06-26 05:21:05terry.reedysetmessages: + msg296850
2017-06-26 04:59:13terry.reedysetpull_requests: + pull_request2444
2017-06-26 04:55:51terry.reedysetmessages: + msg296845
2017-06-24 11:10:30csabellasetnosy: + csabella
messages: + msg296765
2017-06-24 11:05:36csabellasetpull_requests: + pull_request2425
2017-06-22 19:47:44terry.reedysetmessages: + msg296651
stage: patch review -> test needed
2017-06-21 15:50:49terry.reedysetmessages: + msg296563
2017-06-20 19:33:52terry.reedysetassignee: terry.reedy
title: IDLE window won't start or show up after assgining new key in options v2.5.2 and 3.1.1 -> IDLE: refuse invalid key bindings
versions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.4, Python 3.5
2014-10-03 03:09:15terry.reedysetmessages: + msg228301
versions: + Python 3.5, - Python 3.3
2013-07-07 19:18:09ned.deilysetnosy: + terry.reedy, roger.serwy
2013-07-07 16:26:29christian.heimessetstage: patch review
versions: + Python 3.3, Python 3.4, - Python 3.1, Python 3.2
2010-08-03 21:51:05terry.reedysetversions: - Python 2.6, Python 2.5
2009-08-23 03:09:25gpolosettype: performance -> behavior
stage: needs patch -> (no value)
2009-08-22 17:38:16gpolosetstatus: pending -> open

messages: + msg91866
versions: + Python 2.6, Python 2.7, Python 3.2
2009-08-22 12:59:15CaribbeanCruisesetstatus: open -> pending

messages: + msg91863
versions: + Python 2.5, - Python 2.6, Python 2.7, Python 3.2
2009-08-21 15:12:44gpolosetfiles: + tcl_validation.diff
versions: + Python 2.6, Python 2.7, Python 3.2
nosy: + gpolo

messages: + msg91830

keywords: + patch
2009-08-21 09:56:53amaury.forgeotdarcsetnosy: + amaury.forgeotdarc

messages: + msg91812
stage: needs patch
2009-08-20 08:31:19CaribbeanCruisecreate