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 ed0f256c77..2a77d2cfe8 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -212,8 +212,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):