Bug #1531405, format_exception no longer raises an exception if

str(exception) raised an exception.
This commit is contained in:
Neal Norwitz 2006-08-04 04:50:21 +00:00
parent 4b8bd31ef0
commit ff4b63b80f
3 changed files with 51 additions and 5 deletions

View file

@ -202,7 +202,12 @@ def format_exception_only(etype, value):
def _format_final_exc_line(etype, value):
"""Return a list of a single line -- normal case for format_exception_only"""
if value is None or not str(value):
try:
printable = value is None or not str(value)
except:
printable = False
if printable:
line = "%s\n" % etype
else:
line = "%s: %s\n" % (etype, _some_str(value))