Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38d3d22

Browse files
committed
(Merge 3.4) Issue #21398: Fix an unicode error in the pydoc pager when the
documentation contains characters not encodable to the stdout encoding.
2 parents 470cf8d + 0cc45ba commit 38d3d22

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

Lib/pydoc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,9 @@ def bold(self, text):
14041404
def pager(text):
14051405
"""The first time this is called, determine what kind of pager to use."""
14061406
global pager
1407+
# Escape non-encodable characters to avoid encoding errors later
1408+
encoding = sys.getfilesystemencoding()
1409+
text = text.encode(encoding, 'backslashreplace').decode(encoding)
14071410
pager = getpager()
14081411
pager(text)
14091412

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ Core and Builtins
8484
Library
8585
-------
8686

87+
- Issue #21398: Fix an unicode error in the pydoc pager when the documentation
88+
contains characters not encodable to the stdout encoding.
89+
8790
- Issue #16531: ipaddress.IPv4Network and ipaddress.IPv6Network now accept
8891
an (address, netmask) tuple argument, so as to easily construct network
8992
objects from existing addresses.

0 commit comments

Comments
 (0)