Skip to content

Commit 875565b

Browse files
committed
#1065986: add missing error handler in pydoc unicode fix.
1 parent 984f630 commit 875565b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/pydoc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ def _encode(text, encoding=None):
209209
def _binstr(obj):
210210
# Ensure that we have an encoded (binary) string representation of obj,
211211
# even if it is a unicode string.
212-
return obj.encode(_encoding) if isinstance(obj, _unicode) else str(obj)
212+
if isinstance(obj, _unicode):
213+
return obj.encode(_encoding, 'xmlcharrefreplace')
214+
return str(obj)
213215

214216
# ----------------------------------------------------- module manipulation
215217

0 commit comments

Comments
 (0)