mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #21398: Fix an unicode error in the pydoc pager when the documentation
contains characters not encodable to the stdout encoding.
This commit is contained in:
parent
1c6970fac9
commit
0cc45baa3d
2 changed files with 6 additions and 0 deletions
|
@ -1404,6 +1404,9 @@ class _PlainTextDoc(TextDoc):
|
||||||
def pager(text):
|
def pager(text):
|
||||||
"""The first time this is called, determine what kind of pager to use."""
|
"""The first time this is called, determine what kind of pager to use."""
|
||||||
global pager
|
global pager
|
||||||
|
# Escape non-encodable characters to avoid encoding errors later
|
||||||
|
encoding = sys.getfilesystemencoding()
|
||||||
|
text = text.encode(encoding, 'backslashreplace').decode(encoding)
|
||||||
pager = getpager()
|
pager = getpager()
|
||||||
pager(text)
|
pager(text)
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,9 @@ Library
|
||||||
- Issue #21396: Fix TextIOWrapper(..., write_through=True) to not force a
|
- Issue #21396: Fix TextIOWrapper(..., write_through=True) to not force a
|
||||||
flush() on the underlying binary stream. Patch by akira.
|
flush() on the underlying binary stream. Patch by akira.
|
||||||
|
|
||||||
|
- Issue #21398: Fix an unicode error in the pydoc pager when the documentation
|
||||||
|
contains characters not encodable to the stdout encoding.
|
||||||
|
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue