gh-94466: Improve 'help' message in interactive pydoc#148863
Open
Jah-yee wants to merge 2 commits intopython:mainfrom
Open
gh-94466: Improve 'help' message in interactive pydoc#148863Jah-yee wants to merge 2 commits intopython:mainfrom
Jah-yee wants to merge 2 commits intopython:mainfrom
Conversation
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.
|
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 |
Contributor
|
I think proper title would be |
johnslavik
requested changes
Apr 22, 2026
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 likehelp(help), the error message displayed says:However, at the
help>prompt, typinghelp()would exit the interactive help and return to the Python interpreter. The correct command to redisplay the intro is simplyhelp(without parentheses).The Fix
Changed the error message from:
to:
This makes the message consistent with the actual behavior - typing
helpat thehelp>prompt callsself.intro()as expected (line 2041 in pydoc.py).Testing
The fix was verified by examining the code path:
help>prompt typeshelp(help)Helper.help()is called (line 2054) withrequest='help(help)'doc(request, ...)is calleddoc()callsrender_doc()which callsresolve('help(help)', ...)locate()can't findhelp(help)as a module/path, returns NoneImportErroris raised with the improved messageFiles Changed
Lib/pydoc.py: Changed one line in theresolve()function's error messageThank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.
Warmly,
Jah-yee