summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-05-13 00:05:35 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-05-13 00:05:35 (GMT)
commit0cc45baa3d160810f371ef7b69f4b56437bde790 (patch)
treeda1cbc33740565ddfb32d6fe541827e9ed95a72a /Lib/pydoc.py
parent1c6970fac994be2b1f9e3415e09c07ff01657563 (diff)
downloadcpython-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-xLib/pydoc.py3
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)