Skip to content

Commit 66f3964

Browse files
gh-113729: Fix IDLE's Help -> "IDLE Help" menu bug in 3.12.1 and 3.11.7 (#113731)
Co-authored-by: Terry Jan Reedy <[email protected]>
1 parent d0f0308 commit 66f3964

File tree

5 files changed

+26
-20
lines changed

5 files changed

+26
-20
lines changed

Lib/idlelib/News3.txt

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Released on 2024-10-xx
44
=========================
55

66

7+
gh-113729: Fix the "Help -> IDLE Doc" menu bug in 3.11.7 and 3.12.1.
8+
79
gh-57795: Enter selected text into the Find box when opening
810
a Replace dialog. Patch by Roger Serwy and Zackery Spytz.
911

Lib/idlelib/help.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,13 @@ def __init__(self, parent, filename, title):
241241
Toplevel.__init__(self, parent)
242242
self.wm_title(title)
243243
self.protocol("WM_DELETE_WINDOW", self.destroy)
244-
HelpFrame(self, filename).grid(column=0, row=0, sticky='nsew')
244+
self.frame = HelpFrame(self, filename)
245+
self.frame.grid(column=0, row=0, sticky='nsew')
245246
self.grid_columnconfigure(0, weight=1)
246247
self.grid_rowconfigure(0, weight=1)
247248

248249

249-
def copy_strip():
250+
def copy_strip(): # pragma: no cover
250251
"""Copy idle.html to idlelib/help.html, stripping trailing whitespace.
251252
252253
Files with trailing whitespace cannot be pushed to the git cpython
@@ -279,18 +280,18 @@ def copy_strip():
279280
print(f'{src} copied to {dst}')
280281

281282

282-
def _helpwindow(parent):
283+
def show_idlehelp(parent):
283284
"Create HelpWindow; called from Idle Help event handler."
284285
filename = join(abspath(dirname(__file__)), 'help.html')
285-
if not isfile(filename):
286+
if not isfile(filename): # pragma: no cover
286287
# Try copy_strip, present message.
287288
return
288-
HelpWindow(parent, filename, 'IDLE Help (%s)' % python_version())
289+
return HelpWindow(parent, filename, 'IDLE Doc (%s)' % python_version())
289290

290291

291292
if __name__ == '__main__':
292293
from unittest import main
293294
main('idlelib.idle_test.test_help', verbosity=2, exit=False)
294295

295296
from idlelib.idle_test.htest import run
296-
run(_helpwindow)
297+
run(show_idlehelp)

Lib/idlelib/idle_test/htest.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,6 @@
190190
"<Escape>, [Cancel], or [X] prints None to shell"
191191
}
192192

193-
_helpwindow_spec = {
194-
'file': 'help',
195-
'kwds': {},
196-
'msg': "If the help text displays, this works.\n"
197-
"Text is selectable. Window is scrollable."
198-
}
199-
200193
_io_binding_spec = {
201194
'file': 'iomenu',
202195
'kwds': {},
@@ -299,6 +292,13 @@
299292
"Its only action is to close."
300293
}
301294

295+
show_idlehelp_spec = {
296+
'file': 'help',
297+
'kwds': {},
298+
'msg': "If the help text displays, this works.\n"
299+
"Text is selectable. Window is scrollable."
300+
}
301+
302302
_sidebar_number_scrolling_spec = {
303303
'file': 'sidebar',
304304
'kwds': {},

Lib/idlelib/idle_test/test_help.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"Test help, coverage 87%."
1+
"Test help, coverage 94%."
22

33
from idlelib import help
44
import unittest
@@ -8,25 +8,27 @@
88
from tkinter import Tk
99

1010

11-
class HelpFrameTest(unittest.TestCase):
11+
class IdleDocTest(unittest.TestCase):
1212

1313
@classmethod
1414
def setUpClass(cls):
1515
"By itself, this tests that file parsed without exception."
1616
cls.root = root = Tk()
1717
root.withdraw()
18-
helpfile = join(dirname(dirname(abspath(__file__))), 'help.html')
19-
cls.frame = help.HelpFrame(root, helpfile)
18+
cls.window = help.show_idlehelp(root)
2019

2120
@classmethod
2221
def tearDownClass(cls):
23-
del cls.frame
22+
del cls.window
2423
cls.root.update_idletasks()
2524
cls.root.destroy()
2625
del cls.root
2726

28-
def test_line1(self):
29-
text = self.frame.text
27+
def test_1window(self):
28+
self.assertIn('IDLE Doc', self.window.wm_title())
29+
30+
def test_4text(self):
31+
text = self.window.frame.text
3032
self.assertEqual(text.get('1.0', '1.end'), ' IDLE ')
3133

3234

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix the "Help -> IDLE Doc" menu bug in 3.11.7 and 3.12.1.

0 commit comments

Comments
 (0)