I cannot understand why traceback.format_exc () returns "None" in the following example:
import sys
import traceback
def my_excepthook(type, value, tb):
print type.__name__
print value
print traceback.format_exc(tb)
sys.excepthook = my_excepthook
a = "text"
b = 5
error = a + b
Using Python 2.7.1, I get the following output:
TypeError
cannot concatenate 'str' and 'int' objects
None
Instead of "None" on the third line, I expect to get what happens when I comment out the sys.excepthook line:
Traceback (most recent call last):
File "log-test.py", line 17, in <module>
error = a+b
source
share