Say I have something like this, which sends unhanded exceptions to logging.critical():
logging.critical()
import sys def register_handler(): orig_excepthook =
You can just check if sys.excepthook is still built-in function before registering your handler:
sys.excepthook
>>> import sys, types >>> isinstance(sys.excepthook, types.BuiltinFunctionType) True >>> sys.excepthook = lambda x: x >>> isinstance(sys.excepthook, types.BuiltinFunctionType) False