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
Comments
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
|
Thank you for the report. The error line "del mainmenu.menudefs[-2][1][0]" follows this comment. 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] |
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.
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
|
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. |
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
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
|
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).
|
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: But I think this will work for that: |
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:
The text was updated successfully, but these errors were encountered: