[Python-Dev] Python 2.5 bug? Changes in behavior of traceback module
Michael Glassford
glassfordm at hotmail.com
Fri Sep 22 14:24:32 CEST 2006
In Python 2.4, traceback.print_exc() and traceback.format_exc() silently
do nothing if there is no active exception; in Python 2.5, they raise an
exception. Not too difficult to handle, but unexpected (and a pain if
you use it in a lot of places). I assume it was an unintentional change?
Mike
In Python 2.4:
>>> import traceback
>>> traceback.print_exc()
None
>>> traceback.format_exc()
'None\n'
In Python 2.5:
>>> import traceback
>>> traceback.print_exc()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/traceback.py",
line 227, in print_exc
print_exception(etype, value, tb, limit, file)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/traceback.py",
line 126, in print_exception
lines = format_exception_only(etype, value)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/traceback.py",
line 176, in format_exception_only
stype = etype.__name__
AttributeError: 'NoneType' object has no attribute '__name__'
>>> traceback.format_exc()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/traceback.py",
line 236, in format_exc
return ''.join(format_exception(etype, value, tb, limit))
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/traceback.py",
line 145, in format_exception
list = list + format_exception_only(etype, value)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/traceback.py",
line 176, in format_exception_only
stype = etype.__name__
AttributeError: 'NoneType' object has no attribute '__name__'
More information about the Python-Dev
mailing list