Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.12] gh-113729: Fix IDLE's Help -> "IDLE Help" menu bug in 3.12.1 and 3.11.7 (GH-113731) #113765

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/idlelib/News3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Released after 2023-10-02
=========================


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.

Expand Down
13 changes: 7 additions & 6 deletions Lib/idlelib/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -279,18 +280,18 @@ 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__':
from unittest import main
main('idlelib.idle_test.test_help', verbosity=2, exit=False)

from idlelib.idle_test.htest import run
run(_helpwindow)
run(show_idlehelp)
14 changes: 7 additions & 7 deletions Lib/idlelib/idle_test/htest.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,6 @@
"<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': {},
Expand Down Expand Up @@ -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': {},
Expand Down
16 changes: 9 additions & 7 deletions Lib/idlelib/idle_test/test_help.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Test help, coverage 87%."
"Test help, coverage 94%."

from idlelib import help
import unittest
Expand All @@ -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 ')


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