]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-113729: Fix IDLE's Help -> "IDLE Help" menu bug in 3.12.1 and 3.11.7 (#113731)
authorRonald Oussoren <ronaldoussoren@mac.com>
Sat, 6 Jan 2024 06:23:26 +0000 (07:23 +0100)
committerGitHub <noreply@github.com>
Sat, 6 Jan 2024 06:23:26 +0000 (06:23 +0000)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Lib/idlelib/News3.txt
Lib/idlelib/help.py
Lib/idlelib/idle_test/htest.py
Lib/idlelib/idle_test/test_help.py
Misc/NEWS.d/next/IDLE/2024-01-05-12-24-01.gh-issue-113729.qpluea.rst [new file with mode: 0644]

index f38cc96eceb76648faf1e3e8304a5c066e83b10a..84484571a49cf710ca7abeb8f7d5f29deb3c8b8a 100644 (file)
@@ -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.
 
index 3cc7e36e35555b0cf7b6f53040c462b4afe68214..dfccfcb9bda89aa40929f3ed9dd7a66b7e57b507 100644 (file)
@@ -241,12 +241,13 @@ class HelpWindow(Toplevel):
         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
@@ -279,13 +280,13 @@ 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):
+    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__':
@@ -293,4 +294,4 @@ if __name__ == '__main__':
     main('idlelib.idle_test.test_help', verbosity=2, exit=False)
 
     from idlelib.idle_test.htest import run
-    run(_helpwindow)
+    run(show_idlehelp)
index 997f85ff5a78b211a5f81bfb0d5cee0a12e67ba8..a7293774eecaeb957314578baaad65f024b40387 100644 (file)
@@ -190,13 +190,6 @@ HelpSource_spec = {
            "<Escape>, [Cancel], or [X] prints None to shell"
     }
 
-_helpwindow_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 @@ _searchbase_spec = {
            "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': {},
index b542659981894d3e72919ac314612adfa1176316..c528d4e77f8ca7c32aca8e66d5c0183966661546 100644 (file)
@@ -1,4 +1,4 @@
-"Test help, coverage 87%."
+"Test help, coverage 94%."
 
 from idlelib import help
 import unittest
@@ -8,25 +8,27 @@ from os.path import abspath, dirname, join
 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
new file mode 100644 (file)
index 0000000..ecba30c
--- /dev/null
@@ -0,0 +1 @@
+Fix the "Help -> IDLE Doc" menu bug in 3.11.7 and 3.12.1.