mirror of
https://github.com/python/cpython.git
synced 2025-11-28 14:11:15 +00:00
Better fix for bug #1531405, not executing str(value) twice.
This commit is contained in:
parent
e9462c72bd
commit
16183631ed
1 changed files with 3 additions and 7 deletions
|
|
@ -202,15 +202,11 @@ def format_exception_only(etype, value):
|
||||||
|
|
||||||
def _format_final_exc_line(etype, value):
|
def _format_final_exc_line(etype, value):
|
||||||
"""Return a list of a single line -- normal case for format_exception_only"""
|
"""Return a list of a single line -- normal case for format_exception_only"""
|
||||||
try:
|
valuestr = _some_str(value)
|
||||||
printable = value is None or not str(value)
|
if value is None or not valuestr:
|
||||||
except:
|
|
||||||
printable = False
|
|
||||||
|
|
||||||
if printable:
|
|
||||||
line = "%s\n" % etype
|
line = "%s\n" % etype
|
||||||
else:
|
else:
|
||||||
line = "%s: %s\n" % (etype, _some_str(value))
|
line = "%s: %s\n" % (etype, valuestr)
|
||||||
return line
|
return line
|
||||||
|
|
||||||
def _some_str(value):
|
def _some_str(value):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue