diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-05-13 00:05:35 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-05-13 00:05:35 (GMT) |
commit | 0cc45baa3d160810f371ef7b69f4b56437bde790 (patch) | |
tree | da1cbc33740565ddfb32d6fe541827e9ed95a72a /Lib/pydoc.py | |
parent | 1c6970fac994be2b1f9e3415e09c07ff01657563 (diff) | |
download | cpython-0cc45baa3d160810f371ef7b69f4b56437bde790.zip cpython-0cc45baa3d160810f371ef7b69f4b56437bde790.tar.gz cpython-0cc45baa3d160810f371ef7b69f4b56437bde790.tar.bz2 |
Issue #21398: Fix an unicode error in the pydoc pager when the documentation
contains characters not encodable to the stdout encoding.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 5f12832..42f48e1 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) |