Skip to content

gh-69371: Fix pydoc for modules whose path contains undecodable bytes - #155239

Open
serhiy-storchaka wants to merge 3 commits into
python:mainfrom
serhiy-storchaka:gh-69371-pydoc-nondecodable-path
Open

gh-69371: Fix pydoc for modules whose path contains undecodable bytes#155239
serhiy-storchaka wants to merge 3 commits into
python:mainfrom
serhiy-storchaka:gh-69371-pydoc-nondecodable-path

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

python -m pydoc -w and the pydoc HTTP server failed with UnicodeEncodeError if the path of the documented module contains bytes undecodable in the filesystem encoding.

The file URL is now created with urllib.request.pathname2url(), which percent-encodes the path using the filesystem encoding, and characters unencodable in the generated HTML page (which is always UTF-8) are escaped with backslashes.

… bytes

"python -m pydoc -w" and the pydoc HTTP server failed with
UnicodeEncodeError if the path of the documented module contained bytes
undecodable in the filesystem encoding.

The file URL is now created with urllib.request.pathname2url(), which
percent-encodes the path using the filesystem encoding, and characters
unencodable in the generated HTML page (which is always UTF-8) are escaped
with backslashes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes stdlib Standard Library Python modules in the Lib/ directory type-bug An unexpected behavior, bug, or error labels Aug 5, 2026
serhiy-storchaka and others added 2 commits August 5, 2026 18:31
The file system can reject a name with undecodable bytes even if
TESTFN_UNDECODABLE is not None (e.g. on macOS).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
test_html_doc contained the URL in the old format, in which the drive
letter and backslashes of a Windows path were percent-encoded.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes stdlib Standard Library Python modules in the Lib/ directory type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant