Skip to content

Commit

Permalink
gh-95841: IDLE - Revise Windows local doc url (#95845)
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
terryjreedy authored Aug 11, 2022
1 parent 05a0f37 commit bdb2cf8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Lib/idlelib/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,20 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
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,
Expand Down

0 comments on commit bdb2cf8

Please sign in to comment.