Commit 07a943e
gh-69371: Fix pydoc for modules whose path contains undecodable 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>1 parent 1d90627 commit 07a943e
3 files changed
Lines changed: 33 additions & 4 deletions
File tree
- Lib
- test/test_pydoc
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | 74 | | |
76 | 75 | | |
77 | 76 | | |
| |||
792 | 791 | | |
793 | 792 | | |
794 | 793 | | |
795 | | - | |
| 794 | + | |
| 795 | + | |
796 | 796 | | |
797 | 797 | | |
798 | 798 | | |
| |||
1787 | 1787 | | |
1788 | 1788 | | |
1789 | 1789 | | |
1790 | | - | |
| 1790 | + | |
| 1791 | + | |
1791 | 1792 | | |
1792 | 1793 | | |
1793 | 1794 | | |
| |||
2384 | 2385 | | |
2385 | 2386 | | |
2386 | 2387 | | |
2387 | | - | |
| 2388 | + | |
2388 | 2389 | | |
2389 | 2390 | | |
2390 | 2391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
1024 | 1025 | | |
1025 | 1026 | | |
1026 | 1027 | | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
1027 | 1050 | | |
1028 | 1051 | | |
1029 | 1052 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments