summaryrefslogtreecommitdiff
path: root/Lib/traceback.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/traceback.py')
-rw-r--r--Lib/traceback.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py
index 8d28afc0cd..8cb9e281fc 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -211,8 +211,14 @@ def _format_final_exc_line(etype, value):
def _some_str(value):
try:
return str(value)
- except:
- return '<unprintable %s object>' % type(value).__name__
+ except Exception:
+ pass
+ try:
+ value = unicode(value)
+ return value.encode("ascii", "backslashreplace")
+ except Exception:
+ pass
+ return '<unprintable %s object>' % type(value).__name__
def print_exc(limit=None, file=None):