This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Windows "Edit with IDLE >" only has one selection
Type: behavior Stage: needs patch
Components: Installation, Windows Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2022-01-31 23:21 by terry.reedy, last changed 2022-04-11 14:59 by admin.

Messages (6)
msg412224 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2022-01-31 23:21
I have Python and hence IDLE 3.8, 3.9, 3.10, and 3.11 installed.  When I right click a .py file, and then on "Edit with IDLE >" the sub-menu only has '3.11.0a4' listed.  This negates the purpose of having a submenu.

I did some search of previous issues and see a) that I have had more than one version listed before, but b) there have been previous issues with some missing.  I don't know if #27603 has any relevance.

I discovered this when investigating the report at
https://stackoverflow.com/questions/70931009/cant-open-py-files-in-idle-on-desktop-with-python-3-10-2
For that, clicking on the submenu worked for 3.9 but not after upgrading to 3.10. Clicking for me opened the file, but there was only one choice.
msg412225 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2022-02-01 00:13
Check your settings in the registry.

In "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts" there should be a ".py" key, but not necessarily. It should have an "OpenWithList" subkey that contains an "MRUList" value (most recently used list). The value should be a sequence of letters, each of which should be a value name in the key. If the launcher was last used to open a ".py" file, the first letter in the list should be a value with the data "py.exe".

Ideally there should also be a subkey named "UserChoice" that contains a "ProgId" (programmatic identifier) value with the data "Python.File". This sets the "Python.File" ProgID as the locked-in user choice for ".py" files. In the GUI, you can set this in the open-with dialog by selecting "always use this app to open .py files". The selected app should be "Python", with an icon that contains the Python logo and a rocket (the launcher).

If ".py" isn't the locked-in user choice, the shell API will use the most recent user selection in the open-with menu. If there's no user selection, the default association is calculated from "HKCR\.py", which is a merged view of "[HKCU|HKLM]\Software\Classes\.py". The default value of "HKCR\.py" sets the default file association. Ideally it should be "Python.File".

"HKCR\Python.File" is a merged view of "[HKCU|HKLM]\Software\Classes\Python.File". For the merged view, if a value name is defined in the same subkey of HKCU and HKLM, the view prefers the HKCU value. There should be a subkey named "shell\editwithidle\shell". It should define one or more subkeys named "edit3*", such as "edit310". Each should contain a "MUIVerb" value that sets the command description in the "open-with" menu. There should also be a "command" subkey that contains the template command as its default value, e.g. ""C:\Program Files\Python310\pythonw.exe" -m idlelib "%L" %*".
msg412236 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2022-02-01 05:08
The registry settings should be correctly set by the installer.  The bug is that they are not.  I don't touch the registry, and the last 3 versions are less than 2 weeks old.
msg412313 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2022-02-01 21:31
I wonder if you've managed to install the launcher a second time? If the second one is for current user but the first is for local machine, the Open With entries may not be being merged.

In theory, the installer is supposed to detect a previous launcher and match its setting, but the default did change recently, so maybe the detection is not working.

Not sure when I'll get a chance to check it out, so if someone else wants to check and confirm that would be helpful.
msg412319 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2022-02-01 23:48
> the Open With entries may not be being merged.

That would probably be a bug in the Windows shell API. The HKCU and HKLM subkeys of "Software\Classes\Python.File\Shell\editwithidle\shell" are merged in the HKCR view. The same key path can exist in both hives, for which the view contains the union, with precedence for HKCU.

For example, with "Software\Classes\spam":

    import winreg

    hkm = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, r'Software\Classes\spam')
    winreg.SetValueEx(hkm, 'eggs', 0, winreg.REG_SZ, 'hklm')
    winreg.SetValueEx(hkm, 'baz', 0, winreg.REG_SZ, 'hklm')

    hku = winreg.CreateKey(winreg.HKEY_CURRENT_USER, r'Software\Classes\spam')
    winreg.SetValueEx(hku, 'eggs', 0, winreg.REG_SZ, 'hkcu')
    winreg.SetValueEx(hku, 'bam', 0, winreg.REG_SZ, 'hkcu')

    hkr = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, 'spam')

    >>> winreg.EnumValue(hkr, 0)
    ('bam', 'hkcu', 1)
    >>> winreg.EnumValue(hkr, 1)
    ('baz', 'hklm', 1)
    >>> winreg.EnumValue(hkr, 2)
    ('eggs', 'hkcu', 1)

    >>> winreg.EnumValue(hkr, 3)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OSError: [WinError 259] No more data is available
msg412358 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2022-02-02 13:47
True. I guess we need to dig a little deeper to find a cause here. Any 
other ideas?
History
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90752
2022-02-02 13:47:26steve.dowersetmessages: + msg412358
2022-02-01 23:48:12eryksunsetmessages: + msg412319
2022-02-01 21:31:36steve.dowersetmessages: + msg412313
2022-02-01 05:08:29terry.reedysetmessages: + msg412236
2022-02-01 00:13:03eryksunsetnosy: + eryksun
messages: + msg412225
2022-01-31 23:21:47terry.reedycreate