Commit 5551bba0 authored by Guido van Rossum's avatar Guido van Rossum

Patch by Toby Dickenson: don't die when an error occurs during string

conversion in an exception, but instead display <unprintable %s
object> where %s is the type name.
parent 1728a856
......@@ -166,9 +166,15 @@ def format_exception_only(etype, value):
s = s + ' '
list.append('%s^\n' % s)
value = msg
list.append('%s: %s\n' % (str(stype), str(value)))
list.append('%s: %s\n' % (str(stype), _some_str(value)))
return list
def _some_str(value):
try:
return str(value)
except:
return '<unprintable %s object>' % type(value).__name__
def print_exc(limit=None, file=None):
"""This is a shorthand for 'print_exception(sys.exc_type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment