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: python -m idlelib fails on master on Mac OS 10.10.4 #79951

Closed
tirkarthi opened this issue Jan 18, 2019 · 14 comments
Closed

IDLE: python -m idlelib fails on master on Mac OS 10.10.4 #79951

tirkarthi opened this issue Jan 18, 2019 · 14 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@tirkarthi
Copy link
Member

BPO 35770
Nosy @terryjreedy, @taleinat, @csabella, @miss-islington, @tirkarthi
PRs
  • bpo-35770: IDLE macosx deletes Options => Configure IDLE #11614
  • gh-79951: IDLE - Convert menudefs to dictionary #11615
  • [3.7] bpo-35770: IDLE macosx deletes Options => Configure IDLE. (GH-11614) #11616
  • bpo-35770: Fix off-by-1 error. #11618
  • [3.7] bpo-35770: Fix off-by-1 error. (GH-11618) #11619
  • 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 2019-01-18.20:19:06.105>
    created_at = <Date 2019-01-18.06:42:07.560>
    labels = ['3.8', 'expert-IDLE', 'type-bug', '3.7']
    title = 'IDLE: python -m idlelib fails on master on Mac OS 10.10.4'
    updated_at = <Date 2019-01-18.22:29:33.723>
    user = 'https://github.com/tirkarthi'

    bugs.python.org fields:

    activity = <Date 2019-01-18.22:29:33.723>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2019-01-18.20:19:06.105>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2019-01-18.06:42:07.560>
    creator = 'xtreak'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35770
    keywords = ['patch', 'patch', 'patch']
    message_count = 14.0
    messages = ['333945', '333950', '333953', '333959', '333960', '333989', '333993', '333995', '333998', '334001', '334003', '334004', '334016', '334018']
    nosy_count = 5.0
    nosy_names = ['terry.reedy', 'taleinat', 'cheryl.sabella', 'miss-islington', 'xtreak']
    pr_nums = ['11614', '11615', '11616', '11618', '11619']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue35770'
    versions = ['Python 3.7', 'Python 3.8']

    @tirkarthi
    Copy link
    Member Author

    I used to launch IDLE using from master using ./python.exe -m idlelib . It used to work but fails on master on Mac OS now. There seems to be some discussion about this on msg332672 after the commit c1b4b0f. Feel free to close this if it's a known issue. I haven't tested it on latest 3.7 but it seems the commit was also merged to 3.7 so I am just adding 3.8 as version.

    Mac OS version : 10.10.4

    ➜  cpython git:(master) ✗ git checkout c1b4b0f6160e1919394586f44b12538505fed300 Lib/idlelib && ./python.exe -m idlelib
    Traceback (most recent call last):
      File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/runpy.py", line 192, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/idlelib/__main__.py", line 7, in <module>
        idlelib.pyshell.main()
      File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/idlelib/pyshell.py", line 1507, in main
        macosx.setupApp(root, flist)
      File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/idlelib/macosx.py", line 280, in setupApp
        overrideRootMenu(root, flist)
      File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/idlelib/macosx.py", line 181, in overrideRootMenu
        del mainmenu.menudefs[-2][1][0]
    IndexError: list assignment index out of range

    ➜ cpython git:(master) ✗ git checkout c1b4b0f~1 Lib/idlelib && ./python.exe -m idlelib # Works

    $ git show c1b4b0f6160e1919394586f44b12538505fed300
    commit c1b4b0f6160e1919394586f44b12538505fed300 (bpo35557, 35559)
    Author: Cheryl Sabella <cheryl.sabella@gmail.com>
    Date:   Sat Dec 22 01:25:45 2018 -0500
     bpo-22703: IDLE: Improve Code Context and Zoom Height menu labels (GH-11214)
    
    
    
    The Code Context menu label now toggles between Show/Hide Code Context.
     The Zoom Height menu now toggles between Zoom/Restore Height.
     Zoom Height has moved from the Window menu to the Options menu.
    
    
    https://bugs.python.org/issue22703
    

    @tirkarthi tirkarthi added the 3.8 only security fixes label Jan 18, 2019
    @terryjreedy
    Copy link
    Member

    Thank you for the report. The error line "del mainmenu.menudefs[-2][1][0]" follows this comment.
    # Remove the 'Configure Idle' entry from the options menu, it is in the
    # application menu as 'Preferences'
    However, -2 is the Window menu, while Options is -3. Before the c1b patch, Window started with one entry, Zoom Height. This explains why 'Configure IDLE' is still present, and Zoom Height is absent. I did not notice the latter gone before because there is an Apple-supplied Zoom entry, which maximizes width as well as height. I did not notice that this was a replacement.

    After the patch, Window starts empty, which is why even index 0 fails. So try changing -2 to -3 in macosx, getting [-3][1][0] and see if everything works.

    When the dialog is removed, the menu will start with a separator bar. It should go to. So next try [-3][1][0:1]

    @terryjreedy terryjreedy added 3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error labels Jan 18, 2019
    @tirkarthi
    Copy link
    Member Author

    Thanks, I can confirm that your fix launches idlelib.

    Not working : del mainmenu.menudefs[-2][1][0]

    Working : del mainmenu.menudefs[-3][1][0]

    Options menu listing on master with the fix with "Show code context" disabled.

    • Show code context
    • Zoom height

    git checkout v3.7.2 Lib/idlelib/ also works fine so I guess it's a regression but I don't know if this affects other versions of Mac OS.

    Options menu listing on 3.7.2

    • Configure IDLE
    • Code Context

    @csabella
    Copy link
    Contributor

    Karthikeyan,

    Thanks for catching this! Did you want to submit the patch for it or did you want me to make the PR? We're still working on the tests for the menus, so this would just be a code change.

    @tirkarthi
    Copy link
    Member Author

    Cheryl, feel free to submit a patch since I have less exposure to IDLE code. I can manually test the PR on my Mac and report back since this seems to be a Mac specific patch. It would be helpful if someone with access to other Mac OS versions can possibly test this so that it doesn't cause issues on other versions.

    Applying the fix suggested by Terry on my machine and running tests

    $ git diff | cat
    diff --git a/Lib/idlelib/macosx.py b/Lib/idlelib/macosx.py
    index 9be4ed2ec4..16a13a0f2e 100644
    --- a/Lib/idlelib/macosx.py
    +++ b/Lib/idlelib/macosx.py
    @@ -178,7 +178,7 @@ def overrideRootMenu(root, flist):
         del mainmenu.menudefs[-1][1][0:2]
         # Remove the 'Configure Idle' entry from the options menu, it is in the
         # application menu as 'Preferences'
    -    del mainmenu.menudefs[-2][1][0]
    +    del mainmenu.menudefs[-3][1][0]
         menubar = Menu(root)
         root.configure(menu=menubar)
         menudict = {}
    $ ./python.exe -m unittest idlelib.idle_test
    sss......s..........................ss..ss...............................s.......s.............s.sssss...........s.ss..sss.ss....sss..s..s..s...s.....s.s.s................s..s........ss.........ssss.................ssss...................sssssss..s.sss...ss...........sssss.....s.s

    Ran 241 tests in 1.246s

    OK (skipped=66)

    @terryjreedy
    Copy link
    Member

    Since it is my fix, I will write the PR. But first, please test part 2, changing '0' to '0:1', just to make sure it works.

    c1b added 'None,' (for separater bar) after the configdialog entry. When the configdialog entry is removed, the None should be also. On Windows, a menu that starts with None starts with a visible bar. On my Mac Mohave, and perhaps on your machine, it is supressed. But a) I would rather have the data structure match what is shown, and b) we cannot know if the supression occurs on all versions of macOS and predecessors.

    @csabella
    Copy link
    Contributor

    Terry,

    I've started working on a PR to change menudefs to a dictionary. Since dictionaries are in guaranteed order now, it would be easier to reference the menus by their name instead of an index number.

    @tirkarthi
    Copy link
    Member Author

    Since it is my fix, I will write the PR. But first, please test part 2, changing '0' to '0:1', just to make sure it works.

    Just tested it and it works fine with slice. Please find the respective diff and options menu displayed as below :

    git diff | cat
    diff --git a/Lib/idlelib/macosx.py b/Lib/idlelib/macosx.py
    index 9be4ed2ec4..16a13a0f2e 100644
    --- a/Lib/idlelib/macosx.py
    +++ b/Lib/idlelib/macosx.py
    @@ -178,7 +178,7 @@ def overrideRootMenu(root, flist):
         del mainmenu.menudefs[-1][1][0:2]
         # Remove the 'Configure Idle' entry from the options menu, it is in the
         # application menu as 'Preferences'
    -    del mainmenu.menudefs[-2][1][0]
    +    del mainmenu.menudefs[-3][1][0]
         menubar = Menu(root)
         root.configure(menu=menubar)
         menudict = {}

    Options menu

    • Show code context (disabled)
    • Zoom height
    git diff | cat
    diff --git a/Lib/idlelib/macosx.py b/Lib/idlelib/macosx.py
    index 9be4ed2ec4..d6a1b376a1 100644
    --- a/Lib/idlelib/macosx.py
    +++ b/Lib/idlelib/macosx.py
    @@ -178,7 +178,7 @@ def overrideRootMenu(root, flist):
         del mainmenu.menudefs[-1][1][0:2]
         # Remove the 'Configure Idle' entry from the options menu, it is in the
         # application menu as 'Preferences'
    -    del mainmenu.menudefs[-2][1][0]
    +    del mainmenu.menudefs[-3][1][0:1]
         menubar = Menu(root)
         root.configure(menu=menubar)
         menudict = {}

    Options menu

    • Show code context (disabled)
    • Zoom height

    @terryjreedy
    Copy link
    Member

    Cheryl, that sort of change needs an issue for discussion before going very far. I am dubious that it will work (but you can try to show otherwise).

    1. overrideRootMenu does an insertion that I don't think you can do with a dict.
      mainmenu.menudefs[0][1].insert(6, closeItem)

    2. The structure of menudefs is part of the extension interface. (The file should say so.) The test extension zzdummy is incomplete. test_zzdummy has not yet been written, and the definition of ZaDummy.menudefs, currently commented out, needs to me made conditional on whether tests are being run (init.testing)

    @csabella
    Copy link
    Contributor

    I'll submit a quick PR as a PoC. Tal emailed with additional ideas about menudefs, so I agree that another issue would probably be suitable for more discussion.

    I haven't looked at the extensions too closely yet, but the insert you're referring to is actually on the 'values' part, so it's not an issue.

    mainmenu.menudefs[0][1] refers to menu item 0 (file menu) and the [1] means the nested list of tuples within menu 0. I learned that while converting to a dict.

    A trickier one is this because it changes the menus:
    mainmenu.menudefs.insert(0,
    ('application', [
    ('About IDLE', '<<about-idle>>'),
    None,
    ]))

    But I think this will work for that:
    appmenu = {'application': [
    ('About IDLE', '<<about-idle>>'),
    None,
    ]}
    mainmenu.menudefs = {**appmenu, **mainmenu.menudefs}

    @terryjreedy
    Copy link
    Member

    New changeset 39ed289 by Terry Jan Reedy in branch 'master':
    bpo-35770: IDLE macosx deletes Options => Configure IDLE. (GH-11614)
    39ed289

    @miss-islington
    Copy link
    Contributor

    New changeset a01e235 by Miss Islington (bot) in branch '3.7':
    bpo-35770: IDLE macosx deletes Options => Configure IDLE. (GH-11614)
    a01e235

    @terryjreedy
    Copy link
    Member

    New changeset 2cf1dda by Terry Jan Reedy in branch 'master':
    bpo-35770: Fix off-by-1 error. (bpo-11618)
    2cf1dda

    @miss-islington
    Copy link
    Contributor

    New changeset 47290e7 by Miss Islington (bot) in branch '3.7':
    bpo-35770: Fix off-by-1 error. (GH-11618)
    47290e7

    @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 3.8 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    Status: Done
    Development

    No branches or pull requests

    4 participants