FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-69371: Fix pydoc for modules whose path contains undecodable bytes by serhiy-storchaka · Pull Request #155239 · python/cpython · GitHub

Repository navigation

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

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:gh-69371-pydoc-nondecodable-path
Aug 29, 2026
Merged

serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:gh-69371-pydoc-nondecodable-path

Conversation

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 added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 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>
serhiy-storchaka merged commit c8ca336 into python:main Aug 29, 2026
50 checks passed

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

serhiy-storchaka deleted the gh-69371-pydoc-nondecodable-path branch August 29, 2026 19:59

bedevere-app Bot commented Aug 29, 2026

Copy link
Copy Markdown

GH-156608 is a backport of this pull request to the 3.15 branch.

bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Aug 29, 2026

bedevere-app Bot commented Aug 29, 2026

Copy link
Copy Markdown

GH-156609 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 29, 2026

bedevere-app Bot commented Aug 29, 2026

Copy link
Copy Markdown

GH-156610 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 only security fixes label Aug 29, 2026
serhiy-storchaka added a commit that referenced this pull request Aug 29, 2026
…e bytes (GH-155239) (GH-156609)

"python -m pydoc -w" and the pydoc HTTP server failed with
UnicodeEncodeError.  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 UTF-8
page are escaped with backslashes.
(cherry picked from commit c8ca336)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Sep 12, 2026
… bytes (pythonGH-155239)

"python -m pydoc -w" and the pydoc HTTP server failed with
UnicodeEncodeError.  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 UTF-8
page are escaped with backslashes.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Sep 13, 2026
…e bytes (GH-155239) (GH-156610)

"python -m pydoc -w" and the pydoc HTTP server failed with
UnicodeEncodeError.  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 UTF-8
page are escaped with backslashes.
(cherry picked from commit c8ca336)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Oct 10, 2026
…e bytes (GH-155239) (GH-156608)

"python -m pydoc -w" and the pydoc HTTP server failed with
UnicodeEncodeError.  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 UTF-8
page are escaped with backslashes.
(cherry picked from commit c8ca336)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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

Labels

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


Back | FazBrowse Home | New Git URL