diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-05-13 02:06:33 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-05-13 02:06:33 +0200 |
commit | 38d3d22b29abed5a92166b86dddbbc575cf4ae02 (patch) | |
tree | 3c001ff27fb93b74b2468150bf044dc2a631c894 | |
parent | 470cf8dfbedbaa38a9076083a4f697f2b17c0c53 (diff) | |
parent | 0cc45baa3d160810f371ef7b69f4b56437bde790 (diff) | |
download | cpython-git-38d3d22b29abed5a92166b86dddbbc575cf4ae02.tar.gz |
(Merge 3.4) Issue #21398: Fix an unicode error in the pydoc pager when the
documentation contains characters not encodable to the stdout encoding.
-rwxr-xr-x | Lib/pydoc.py | 3 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 5f128320d2..42f48e1d63 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1404,6 +1404,9 @@ class _PlainTextDoc(TextDoc): def pager(text): """The first time this is called, determine what kind of pager to use.""" global pager + # Escape non-encodable characters to avoid encoding errors later + encoding = sys.getfilesystemencoding() + text = text.encode(encoding, 'backslashreplace').decode(encoding) pager = getpager() pager(text) @@ -84,6 +84,9 @@ Core and Builtins Library ------- +- Issue #21398: Fix an unicode error in the pydoc pager when the documentation + contains characters not encodable to the stdout encoding. + - Issue #16531: ipaddress.IPv4Network and ipaddress.IPv6Network now accept an (address, netmask) tuple argument, so as to easily construct network objects from existing addresses. |