From: Georg Brandl Date: Fri, 4 Aug 2006 18:07:34 +0000 (+0000) Subject: Better fix for bug #1531405, not executing str(value) twice. X-Git-Tag: v2.5c1~144 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=16183631ede0656a5cfd58626419cc081d281fff;p=thirdparty%2FPython%2Fcpython.git Better fix for bug #1531405, not executing str(value) twice. --- diff --git a/Lib/traceback.py b/Lib/traceback.py index 505a3052ccfe..75e1fcffa382 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -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):