From f5dadc6f7b6ec7acc0d8d8afc563bf17f674555c Mon Sep 17 00:00:00 2001 From: Ronald Oussoren Date: Fri, 5 Jan 2024 12:24:05 +0100 Subject: [PATCH 1/2] gh-113729: Fix the Help -> "IDLE Help" menu in IDLE --- Lib/idlelib/help.py | 4 ++-- Lib/idlelib/idle_test/htest.py | 2 +- .../next/IDLE/2024-01-05-12-24-01.gh-issue-113729.qpluea.rst | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/IDLE/2024-01-05-12-24-01.gh-issue-113729.qpluea.rst diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py index 3cc7e36e35555b..f5ac938cf7cbc6 100644 --- a/Lib/idlelib/help.py +++ b/Lib/idlelib/help.py @@ -279,7 +279,7 @@ def copy_strip(): print(f'{src} copied to {dst}') -def _helpwindow(parent): +def show_idlehelp(parent): "Create HelpWindow; called from Idle Help event handler." filename = join(abspath(dirname(__file__)), 'help.html') if not isfile(filename): @@ -293,4 +293,4 @@ def _helpwindow(parent): main('idlelib.idle_test.test_help', verbosity=2, exit=False) from idlelib.idle_test.htest import run - run(_helpwindow) + run(show_idlehelp) diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py index 997f85ff5a78b2..9209a1181a9f05 100644 --- a/Lib/idlelib/idle_test/htest.py +++ b/Lib/idlelib/idle_test/htest.py @@ -190,7 +190,7 @@ ", [Cancel], or [X] prints None to shell" } -_helpwindow_spec = { +show_idlehelp_spec = { 'file': 'help', 'kwds': {}, 'msg': "If the help text displays, this works.\n" diff --git a/Misc/NEWS.d/next/IDLE/2024-01-05-12-24-01.gh-issue-113729.qpluea.rst b/Misc/NEWS.d/next/IDLE/2024-01-05-12-24-01.gh-issue-113729.qpluea.rst new file mode 100644 index 00000000000000..3c1ebe94f61ae6 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2024-01-05-12-24-01.gh-issue-113729.qpluea.rst @@ -0,0 +1 @@ +Fix the "Help -> IDLE Help" menu. From 77d3a44778efe034604091a6976e7e3d5bbbdcf7 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sat, 6 Jan 2024 01:03:36 -0500 Subject: [PATCH 2/2] Unittest and other changes. --- Lib/idlelib/News3.txt | 2 ++ Lib/idlelib/help.py | 9 +++++---- Lib/idlelib/idle_test/htest.py | 14 +++++++------- Lib/idlelib/idle_test/test_help.py | 16 +++++++++------- ...024-01-05-12-24-01.gh-issue-113729.qpluea.rst | 2 +- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Lib/idlelib/News3.txt b/Lib/idlelib/News3.txt index f38cc96eceb766..84484571a49cf7 100644 --- a/Lib/idlelib/News3.txt +++ b/Lib/idlelib/News3.txt @@ -4,6 +4,8 @@ Released on 2024-10-xx ========================= +gh-113729: Fix the "Help -> IDLE Doc" menu bug in 3.11.7 and 3.12.1. + gh-57795: Enter selected text into the Find box when opening a Replace dialog. Patch by Roger Serwy and Zackery Spytz. diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py index f5ac938cf7cbc6..dfccfcb9bda89a 100644 --- a/Lib/idlelib/help.py +++ b/Lib/idlelib/help.py @@ -241,12 +241,13 @@ def __init__(self, parent, filename, title): Toplevel.__init__(self, parent) self.wm_title(title) self.protocol("WM_DELETE_WINDOW", self.destroy) - HelpFrame(self, filename).grid(column=0, row=0, sticky='nsew') + self.frame = HelpFrame(self, filename) + self.frame.grid(column=0, row=0, sticky='nsew') self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) -def copy_strip(): +def copy_strip(): # pragma: no cover """Copy idle.html to idlelib/help.html, stripping trailing whitespace. Files with trailing whitespace cannot be pushed to the git cpython @@ -282,10 +283,10 @@ def copy_strip(): def show_idlehelp(parent): "Create HelpWindow; called from Idle Help event handler." filename = join(abspath(dirname(__file__)), 'help.html') - if not isfile(filename): + if not isfile(filename): # pragma: no cover # Try copy_strip, present message. return - HelpWindow(parent, filename, 'IDLE Help (%s)' % python_version()) + return HelpWindow(parent, filename, 'IDLE Doc (%s)' % python_version()) if __name__ == '__main__': diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py index 9209a1181a9f05..a7293774eecaeb 100644 --- a/Lib/idlelib/idle_test/htest.py +++ b/Lib/idlelib/idle_test/htest.py @@ -190,13 +190,6 @@ ", [Cancel], or [X] prints None to shell" } -show_idlehelp_spec = { - 'file': 'help', - 'kwds': {}, - 'msg': "If the help text displays, this works.\n" - "Text is selectable. Window is scrollable." - } - _io_binding_spec = { 'file': 'iomenu', 'kwds': {}, @@ -299,6 +292,13 @@ "Its only action is to close." } +show_idlehelp_spec = { + 'file': 'help', + 'kwds': {}, + 'msg': "If the help text displays, this works.\n" + "Text is selectable. Window is scrollable." + } + _sidebar_number_scrolling_spec = { 'file': 'sidebar', 'kwds': {}, diff --git a/Lib/idlelib/idle_test/test_help.py b/Lib/idlelib/idle_test/test_help.py index b542659981894d..c528d4e77f8ca7 100644 --- a/Lib/idlelib/idle_test/test_help.py +++ b/Lib/idlelib/idle_test/test_help.py @@ -1,4 +1,4 @@ -"Test help, coverage 87%." +"Test help, coverage 94%." from idlelib import help import unittest @@ -8,25 +8,27 @@ from tkinter import Tk -class HelpFrameTest(unittest.TestCase): +class IdleDocTest(unittest.TestCase): @classmethod def setUpClass(cls): "By itself, this tests that file parsed without exception." cls.root = root = Tk() root.withdraw() - helpfile = join(dirname(dirname(abspath(__file__))), 'help.html') - cls.frame = help.HelpFrame(root, helpfile) + cls.window = help.show_idlehelp(root) @classmethod def tearDownClass(cls): - del cls.frame + del cls.window cls.root.update_idletasks() cls.root.destroy() del cls.root - def test_line1(self): - text = self.frame.text + def test_1window(self): + self.assertIn('IDLE Doc', self.window.wm_title()) + + def test_4text(self): + text = self.window.frame.text self.assertEqual(text.get('1.0', '1.end'), ' IDLE ') diff --git a/Misc/NEWS.d/next/IDLE/2024-01-05-12-24-01.gh-issue-113729.qpluea.rst b/Misc/NEWS.d/next/IDLE/2024-01-05-12-24-01.gh-issue-113729.qpluea.rst index 3c1ebe94f61ae6..ecba30c894c34e 100644 --- a/Misc/NEWS.d/next/IDLE/2024-01-05-12-24-01.gh-issue-113729.qpluea.rst +++ b/Misc/NEWS.d/next/IDLE/2024-01-05-12-24-01.gh-issue-113729.qpluea.rst @@ -1 +1 @@ -Fix the "Help -> IDLE Help" menu. +Fix the "Help -> IDLE Doc" menu bug in 3.11.7 and 3.12.1.