From: R David Murray Date: Sun, 5 Jan 2014 22:14:08 +0000 (-0500) Subject: #1065986: add missing error handler in pydoc unicode fix. X-Git-Tag: v2.7.8~151 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=875565bbd602825fd24eab2978ea4a7f81cfd7cc;p=python #1065986: add missing error handler in pydoc unicode fix. --- 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