[issue42308] Add threading.__excepthook__ similar to sys.__excepthook__
STINNER Victor
report at bugs.python.org
Tue Nov 10 08:45:06 EST 2020
STINNER Victor <vstinner at python.org> added the comment:
Can't you do that in your own hook? For example:
orig_hook = threading.excepthook
threading.excepthook = myhook
def myhook(args):
try:
...
except:
print("too bad!")
orig_hook(args)
I found one interesting usage of sys.__excepthook__ in code.InteractiveInterpreter:
if sys.excepthook is sys.__excepthook__:
lines = traceback.format_exception_only(type, value)
self.write(''.join(lines))
else:
# If someone has set sys.excepthook, we let that take precedence
# over self.write
sys.excepthook(type, value, tb)
So it seems like sys.__excepthook__ is useful ;-)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42308>
_______________________________________
More information about the Python-bugs-list
mailing list