Skip to content

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

Open
serhiy-storchaka wants to merge 1 commit 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 1 commit 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
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