mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
bpo-42639: atexit now logs callbacks exceptions (GH-23771)
At Python exit, if a callback registered with atexit.register() fails, its exception is now logged. Previously, only some exceptions were logged, and the last exception was always silently ignored. Add _PyAtExit_Call() function and remove PyInterpreterState.atexit_func member. call_py_exitfuncs() now calls directly _PyAtExit_Call(). The atexit module must now always be built as a built-in module.
This commit is contained in:
parent
83d52044ae
commit
357704c9f2
8 changed files with 53 additions and 28 deletions
|
@ -2632,19 +2632,16 @@ Py_ExitStatusException(PyStatus status)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* Clean up and exit */
|
||||
|
||||
static void
|
||||
call_py_exitfuncs(PyThreadState *tstate)
|
||||
{
|
||||
PyInterpreterState *interp = tstate->interp;
|
||||
if (interp->atexit_func == NULL)
|
||||
return;
|
||||
|
||||
interp->atexit_func(interp->atexit_module);
|
||||
_PyErr_Clear(tstate);
|
||||
_PyAtExit_Call(tstate->interp->atexit_module);
|
||||
}
|
||||
|
||||
|
||||
/* Wait until threading._shutdown completes, provided
|
||||
the threading module was imported in the first place.
|
||||
The shutdown routine will wait until all non-daemon
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue