From 875565bbd602825fd24eab2978ea4a7f81cfd7cc Mon Sep 17 00:00:00 2001 From: R David Murray Date: Sun, 5 Jan 2014 17:14:08 -0500 Subject: [PATCH] #1065986: add missing error handler in pydoc unicode fix. --- Lib/pydoc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/pydoc.py b/Lib/pydoc.py index e8b6c08bd3..160ad4acf7 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 -- 2.50.1