Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDLE: refuse invalid key bindings #50988

Closed
CaribbeanCruise mannequin opened this issue Aug 20, 2009 · 12 comments
Closed

IDLE: refuse invalid key bindings #50988

CaribbeanCruise mannequin opened this issue Aug 20, 2009 · 12 comments
Assignees
Labels
3.7 (EOL) end of life topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@CaribbeanCruise
Copy link
Mannequin

CaribbeanCruise mannequin commented Aug 20, 2009

BPO 6739
Nosy @terryjreedy, @amauryfa, @serwy, @csabella
PRs
  • bpo-6739: IDLE: Check for valid keybinding in config_keys #2377
  • [3.6] bpo-6739: IDLE: Check for valid keybinding in config_keys (GH-2… #2397
  • Files
  • tcl_validation.diff
  • 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 = <Date 2017-06-26.05:38:16.843>
    created_at = <Date 2009-08-20.08:31:19.396>
    labels = ['expert-IDLE', 'type-bug', '3.7']
    title = 'IDLE: refuse invalid key bindings'
    updated_at = <Date 2017-06-26.05:38:16.842>
    user = 'https://bugs.python.org/CaribbeanCruise'

    bugs.python.org fields:

    activity = <Date 2017-06-26.05:38:16.842>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2017-06-26.05:38:16.843>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2009-08-20.08:31:19.396>
    creator = 'CaribbeanCruise'
    dependencies = []
    files = ['14761']
    hgrepos = []
    issue_num = 6739
    keywords = ['patch']
    message_count = 12.0
    messages = ['91762', '91812', '91830', '91863', '91866', '228301', '296563', '296651', '296765', '296845', '296850', '296851']
    nosy_count = 6.0
    nosy_names = ['terry.reedy', 'amaury.forgeotdarc', 'gpolo', 'roger.serwy', 'CaribbeanCruise', 'cheryl.sabella']
    pr_nums = ['2377', '2397']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue6739'
    versions = ['Python 3.6', 'Python 3.7']

    @CaribbeanCruise
    Copy link
    Mannequin Author

    CaribbeanCruise mannequin commented Aug 20, 2009

    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?

    @CaribbeanCruise CaribbeanCruise mannequin added performance Performance or resource usage topic-IDLE labels Aug 20, 2009
    @amauryfa
    Copy link
    Member

    • find your .idlerc directory (probably in %USERPROFILE%)

    • edit config-extensions.cfg

    • remove the <Control-Shift> binding

    • write a patch that refuses invalid keysims.

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Aug 21, 2009

    Here is a patch that changes IDLE to refuse invalid key bindings.

    @CaribbeanCruise
    Copy link
    Mannequin Author

    CaribbeanCruise mannequin commented Aug 22, 2009

    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.

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Aug 22, 2009

    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.

    @gpolo gpolo mannequin added type-bug An unexpected behavior, bug, or error and removed performance Performance or resource usage labels Aug 23, 2009
    @terryjreedy
    Copy link
    Member

    bpo-21519 also patched key validation

    @terryjreedy terryjreedy added the 3.7 (EOL) end of life label Jun 20, 2017
    @terryjreedy terryjreedy changed the 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 Jun 20, 2017
    @terryjreedy terryjreedy self-assigned this Jun 20, 2017
    @terryjreedy
    Copy link
    Member

    I believe patch for bpo-21519 affects area of file patched here.

    @terryjreedy
    Copy link
    Member

    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>'.

    @csabella
    Copy link
    Contributor

    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.

    @terryjreedy
    Copy link
    Member

    New changeset 8c78aa7 by terryjreedy (csabella) in branch 'master':
    bpo-6739: IDLE: Check for valid keybinding in config_keys (bpo-2377)
    8c78aa7

    @terryjreedy
    Copy link
    Member

    New changeset 64a0c26 by terryjreedy in branch '3.6':
    [3.6] bpo-6739: IDLE: Check for valid keybinding in config_keys (GH-2377) (bpo-2397)
    64a0c26

    @terryjreedy
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants