You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IDLE: python -m idlelib fails on master on Mac OS 10.10.4 #79951
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=<Date2019-01-18.20:19:06.105>created_at=<Date2019-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=<Date2019-01-18.22:29:33.723>user='https://github.com/tirkarthi'
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_mainreturn _run_code(code, main_globals, None,
File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/runpy.py", line 85, in _run_codeexec(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 overrideRootMenudel mainmenu.menudefs[-2][1][0]
IndexError: list assignment index out of range
$ 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
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]
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 = {}
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.
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 = {}
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}
Activity
tirkarthi commentedon Jan 18, 2019
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 c1b4b0f~1 Lib/idlelib && ./python.exe -m idlelib # Works
terryjreedy commentedon Jan 18, 2019
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]
tirkarthi commentedon 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.
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
csabella commentedon Jan 18, 2019
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 commentedon Jan 18, 2019
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
Ran 241 tests in 1.246s
OK (skipped=66)
terryjreedy commentedon Jan 18, 2019
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 commentedon Jan 18, 2019
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 commentedon Jan 18, 2019
Just tested it and it works fine with slice. Please find the respective diff and options menu displayed as below :
Options menu
Options menu
terryjreedy commentedon Jan 18, 2019
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)
csabella commentedon Jan 18, 2019
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 commentedon Jan 18, 2019
New changeset 39ed289 by Terry Jan Reedy in branch 'master':
bpo-35770: IDLE macosx deletes Options => Configure IDLE. (GH-11614)
39ed289
miss-islington commentedon Jan 18, 2019
New changeset a01e235 by Miss Islington (bot) in branch '3.7':
bpo-35770: IDLE macosx deletes Options => Configure IDLE. (GH-11614)
a01e235
terryjreedy commentedon Jan 18, 2019
New changeset 2cf1dda by Terry Jan Reedy in branch 'master':
bpo-35770: Fix off-by-1 error. (bpo-11618)
2cf1dda
miss-islington commentedon Jan 18, 2019
New changeset 47290e7 by Miss Islington (bot) in branch '3.7':
bpo-35770: Fix off-by-1 error. (GH-11618)
47290e7