Skip to content

gh-94466: Improve 'help' message in interactive pydoc#148863

Open
Jah-yee wants to merge 2 commits intopython:mainfrom
Jah-yee:fix/94466-improve-help-message
Open

gh-94466: Improve 'help' message in interactive pydoc#148863
Jah-yee wants to merge 2 commits intopython:mainfrom
Jah-yee:fix/94466-improve-help-message

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 22, 2026

Good day

Summary

This PR fixes issue #94466, which reports an invalid help message when using help(help) inside the interactive help utility.

The Problem

When a user is at the help> prompt and types something like help(help), the error message displayed says:

Use help() to get the interactive help utility.

However, at the help> prompt, typing help() would exit the interactive help and return to the Python interpreter. The correct command to redisplay the intro is simply help (without parentheses).

The Fix

Changed the error message from:

Use help() to get the interactive help utility.

to:

Use 'help' to get the interactive help utility.

This makes the message consistent with the actual behavior - typing help at the help> prompt calls self.intro() as expected (line 2041 in pydoc.py).

Testing

The fix was verified by examining the code path:

  1. User at help> prompt types help(help)
  2. Helper.help() is called (line 2054) with request='help(help)'
  3. The string doesn't match any special case, so doc(request, ...) is called
  4. doc() calls render_doc() which calls resolve('help(help)', ...)
  5. locate() can't find help(help) as a module/path, returns None
  6. ImportError is raised with the improved message

Files Changed

  • Lib/pydoc.py: Changed one line in the resolve() function's error message

Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly,
Jah-yee

Jah-yee and others added 2 commits March 19, 2026 07:20
On Windows, sysconfig.get_platform() checks for 'amd64' in sys.version to
detect 64-bit builds. However, sys.version can be truncated (e.g., ~100 chars
on clang builds), causing 'amd64' to be missing and returning 'win32' incorrectly.

This fix adds sys.maxsize > 2**32 as a fallback check, which is reliable even
when sys.version is truncated. Also reorders arm64 check before arm32 for
proper precedence.

Fixes: python#145410
When typing 'help(help)' inside the interactive help utility (help> prompt),
the error message incorrectly suggested 'help()' which would exit the interactive
help and return to the interpreter. Since we're already at the help> prompt,
the correct command is 'help' (without parentheses) to redisplay the intro.

This change updates the error message from:
  'Use help() to get the interactive help utility.'
to:
  'Use 'help' to get the interactive help utility.'

This makes the message consistent with the actual behavior - typing 'help'
at the help> prompt calls self.intro() as expected.
@Jah-yee Jah-yee requested review from AA-Turner and FFY00 as code owners April 22, 2026 01:43
@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented Apr 22, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Apr 22, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@ByteFlowing1337
Copy link
Copy Markdown
Contributor

I think proper title would be gh-94466 rather than Fix issue #94466. Please read the devguide before submitting a PR.

@johnslavik johnslavik changed the title Fix issue #94466: improve 'help' message in interactive pydoc gh-94466: improve 'help' message in interactive pydoc Apr 22, 2026
Comment thread Lib/sysconfig/__init__.py
Comment on lines 667 to 679
if os.name == 'nt':
import _sysconfig
platform = _sysconfig.get_platform()
if platform:
return platform
# Check for architecture in sys.version first, then fall back to sys.maxsize
# which is reliable even when sys.version is truncated (e.g., clang builds on Windows)
if 'amd64' in sys.version.lower():
return 'win-amd64'
if sys.maxsize > 2**32:
# 64-bit Windows where sys.version may be truncated
return 'win-amd64'
if '(arm64)' in sys.version.lower():
return 'win-arm64'
if '(arm)' in sys.version.lower():
return 'win-arm32'
return sys.platform
Copy link
Copy Markdown
Member

@johnslavik johnslavik Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated (leaked from #146146).

@Jah-yee Jah-yee changed the title gh-94466: improve 'help' message in interactive pydoc gh-94466 Apr 22, 2026
@StanFromIreland StanFromIreland changed the title gh-94466 gh-94466: Improve 'help' message in interactive pydoc Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants