]> granicus.if.org Git - python/commitdiff
Better fix for bug #1531405, not executing str(value) twice.
authorGeorg Brandl <georg@python.org>
Fri, 4 Aug 2006 18:07:34 +0000 (18:07 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 4 Aug 2006 18:07:34 +0000 (18:07 +0000)
Lib/traceback.py

index 505a3052ccfe8effa4a982805d5918356ee4d696..75e1fcffa382e9f6991819adc1f3b588016c8a20 100644 (file)
@@ -202,15 +202,11 @@ 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"""
-    try:
-        printable = value is None or not str(value)
-    except:
-        printable = False
-
-    if printable:
+    valuestr = _some_str(value)
+    if value is None or not valuestr:
         line = "%s\n" % etype
     else:
-        line = "%s: %s\n" % (etype, _some_str(value))
+        line = "%s: %s\n" % (etype, valuestr)
     return line
 
 def _some_str(value):