From eb11a46ffa30809455507b6ed37bc5a367745dcc Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Tue, 9 Aug 2022 20:57:50 -0400 Subject: [PATCH 1/2] gh-95841: IDLE - Revise Windows local doc url #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. --- Lib/idlelib/editor.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 859a288b4bc677..5ed7e3c528663e 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -8,6 +8,7 @@ import tokenize import traceback import webbrowser +import winreg from tkinter import * from tkinter.font import Font @@ -86,10 +87,19 @@ 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 + docfile = "Dummy^file&name*that(should)fail-isfile#check" + 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, From b1ca323490cb6a9fb35762c4fb153a1176f612c0 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Thu, 11 Aug 2022 01:23:05 -0400 Subject: [PATCH 2/2] Fix import, initialization. --- Lib/idlelib/editor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 5ed7e3c528663e..08d6aa2efde22a 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -8,7 +8,6 @@ import tokenize import traceback import webbrowser -import winreg from tkinter import * from tkinter.font import Font @@ -87,7 +86,8 @@ 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': - docfile = "Dummy^file&name*that(should)fail-isfile#check" + import winreg # Windows only, block only executed once. + docfile = '' KEY = (rf"Software\Python\PythonCore\{sys.winver}" r"\Help\Main Python Documentation") try: