Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.13] gh-138568: Makehelp mode in PyREPL not exit on empty line input (GH-143512)#143520

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ambv merged 1 commit intopython:3.13fromambv:backport-b3e4a34-3.13
Jan 7, 2026
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletionLib/pydoc.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2028,10 +2028,11 @@ def interact(self):
while True:
try:
request = self.getline('help> ')
if not request: break
except (KeyboardInterrupt, EOFError):
break
request = request.strip()
if not request:
continue # back to the prompt

# Make sure significant trailing quoting marks of literals don't
# get deleted while cleaning input
Expand Down
37 changes: 37 additions & 0 deletionsLib/test/test_pydoc/test_pydoc.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2175,10 +2175,47 @@ def test_url_requests(self):


class TestHelper(unittest.TestCase):
def mock_interactive_session(self, inputs):
"""
Given a list of inputs, run an interactive help session. Returns a string
of what would be shown on screen.
"""
input_iter = iter(inputs)

def mock_getline(prompt):
output.write(prompt)
next_input = next(input_iter)
output.write(next_input + os.linesep)
return next_input

with captured_stdout() as output:
helper = pydoc.Helper(output=output)
with unittest.mock.patch.object(helper, "getline", mock_getline):
helper.interact()

# handle different line endings across platforms consistently
return output.getvalue().strip().splitlines(keepends=False)

def test_keywords(self):
self.assertEqual(sorted(pydoc.Helper.keywords),
sorted(keyword.kwlist))

def test_interact_empty_line_continues(self):
# gh-138568: test pressing Enter without input should continue in help session
self.assertEqual(
self.mock_interactive_session(["", " ", "quit"]),
["help> ", "help> ", "help> quit"],
)

def test_interact_quit_commands_exit(self):
quit_commands = ["quit", "q", "exit"]
for quit_cmd in quit_commands:
with self.subTest(quit_command=quit_cmd):
self.assertEqual(
self.mock_interactive_session([quit_cmd]),
[f"help> {quit_cmd}"],
)


class PydocWithMetaClasses(unittest.TestCase):
def tearDown(self):
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
Adjusted the built-in :func:`help` function so that empty inputs are ignored in
interactive mode.

[8]ページ先頭

©2009-2026 Movatter.jp