]> granicus.if.org Git - python/commitdiff
#1065986: add missing error handler in pydoc unicode fix.
authorR David Murray <rdmurray@bitdance.com>
Sun, 5 Jan 2014 22:14:08 +0000 (17:14 -0500)
committerR David Murray <rdmurray@bitdance.com>
Sun, 5 Jan 2014 22:14:08 +0000 (17:14 -0500)
Lib/pydoc.py

index e8b6c08bd3501e93f860195e44a89e5015b6fb0d..160ad4acf7dcc9f6a7afc446bddcf286cf645fc6 100755 (executable)
@@ -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