Repository navigation
IDLE: python -m idlelib fails on master on Mac OS 10.10.4 #79951
Description
Activity
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/issue22703Thank 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]
- added3.7 (EOL)end of lifeend of lifetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Jan 18, 2019 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
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.
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)
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.
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.
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
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).
-
overrideRootMenu does an insertion that I don't think you can do with a dict.
mainmenu.menudefs[0][1].insert(6, closeItem) -
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)
-
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}
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
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:
bugs.python.org fields: