summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-08-04 18:07:34 (GMT)
committerGeorg Brandl <georg@python.org>2006-08-04 18:07:34 (GMT)
commit16183631ede0656a5cfd58626419cc081d281fff (patch)
treed57db557a6de1c79fd1117ed356a13338857c81e /Lib
parente9462c72bd3db9daca682bc7f993f9c77a4022db (diff)
downloadcpython-16183631ede0656a5cfd58626419cc081d281fff.zip
cpython-16183631ede0656a5cfd58626419cc081d281fff.tar.gz
cpython-16183631ede0656a5cfd58626419cc081d281fff.tar.bz2
Better fix for bug #1531405, not executing str(value) twice.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/traceback.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py
index 505a305..75e1fcf 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):