summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index e8b6c08..160ad4a 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -209,7 +209,9 @@ else:
def _binstr(obj):
# Ensure that we have an encoded (binary) string representation of obj,
# even if it is a unicode string.
- return obj.encode(_encoding) if isinstance(obj, _unicode) else str(obj)
+ if isinstance(obj, _unicode):
+ return obj.encode(_encoding, 'xmlcharrefreplace')
+ return str(obj)
# ----------------------------------------------------- module manipulation