Skip to content

Commit f3b2d4c

Browse files
authoredAug 12, 2022
gh-95841: IDLE - Revise Windows local doc url (GH-95845) (#95905)
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: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Steve Dower Approved by Steve Dower, #95845 (review), 2nd subblock. (cherry picked from commit bdb2cf8e913c041f26e8976abe58414819b3e8ff)
1 parent 6c93f48 commit f3b2d4c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed
 

‎idlelib/editor.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,20 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
8686
dochome = os.path.join(basepath, pyver,
8787
'Doc', 'index.html')
8888
elif sys.platform[:3] == 'win':
89-
chmfile = os.path.join(sys.base_prefix, 'Doc',
90-
'Python%s.chm' % _sphinx_version())
91-
if os.path.isfile(chmfile):
92-
dochome = chmfile
89+
import winreg # Windows only, block only executed once.
90+
docfile = ''
91+
KEY = (rf"Software\Python\PythonCore\{sys.winver}"
92+
r"\Help\Main Python Documentation")
93+
try:
94+
docfile = winreg.QueryValue(winreg.HKEY_CURRENT_USER, KEY)
95+
except FileNotFoundError:
96+
try:
97+
docfile = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
98+
KEY)
99+
except FileNotFoundError:
100+
pass
101+
if os.path.isfile(docfile):
102+
dochome = docfile
93103
elif sys.platform == 'darwin':
94104
# documentation may be stored inside a python framework
95105
dochome = os.path.join(sys.base_prefix,

0 commit comments

Comments
 (0)
Please sign in to comment.