summaryrefslogtreecommitdiff
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
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 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)