[Python-Dev] bpo-36829: Add sys.unraisablehook()

Victor Stinner vstinner at redhat.com
Thu May 16 05:57:24 EDT 2019

Le jeu. 16 mai 2019 à 04:44, Nathaniel Smith <njs at pobox.com> a écrit :
> What happens if the hook raises an exception?

Aha, thanks for asking the question!

If there is a custom hook and the hook fails, the default hook logs
the exception of the custom hook.

Technically, even if the default hook fails, the default hook is
called again to handle its own exception :-)

The fallback uses a direct access to the C implementation of the
default hook which reduces the risk of bugs.

My implementation contains an unit test to ensure that if a custom
hook raises an exception, it's a logged as expected ;-)

Night gathers, and now my watch begins. It shall not end until my death.

More information about the Python-Dev mailing list