]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95841: IDLE - Revise Windows local doc url (GH-95845)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 11 Aug 2022 21:35:36 +0000 (14:35 -0700)
committerGitHub <noreply@github.com>
Thu, 11 Aug 2022 21:35:36 +0000 (14:35 -0700)
GH-91242 replaced the Windows chm help file with a copy
of the html docs.  This PR replaces the IDLE code that
fetches the Windows local help url passed to os.startfile.
Co-authored-by: Steve Dower
(cherry picked from commit bdb2cf8e913c041f26e8976abe58414819b3e8ff)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Lib/idlelib/editor.py

index 859a288b4bc6772aa8c00d23a9581e73c70ed989..08d6aa2efde22adf0a41a180beb1dce47f65ec69 100644 (file)
@@ -86,10 +86,20 @@ class EditorWindow:
                     dochome = os.path.join(basepath, pyver,
                                            'Doc', 'index.html')
             elif sys.platform[:3] == 'win':
-                chmfile = os.path.join(sys.base_prefix, 'Doc',
-                                       'Python%s.chm' % _sphinx_version())
-                if os.path.isfile(chmfile):
-                    dochome = chmfile
+                import winreg  # Windows only, block only executed once.
+                docfile = ''
+                KEY = (rf"Software\Python\PythonCore\{sys.winver}"
+                        r"\Help\Main Python Documentation")
+                try:
+                    docfile = winreg.QueryValue(winreg.HKEY_CURRENT_USER, KEY)
+                except FileNotFoundError:
+                    try:
+                        docfile = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
+                                                    KEY)
+                    except FileNotFoundError:
+                        pass
+                if os.path.isfile(docfile):
+                    dochome = docfile
             elif sys.platform == 'darwin':
                 # documentation may be stored inside a python framework
                 dochome = os.path.join(sys.base_prefix,