diff options
author | Victor Stinner <vstinner@python.org> | 2020-12-14 23:07:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 23:07:54 +0100 |
commit | 357704c9f2375f29ed5b3a93adac086fa714538d (patch) | |
tree | 8b69403f419da52a6728c8557e1169aaf23c9e2e /Include | |
parent | bpo-42639: Cleanup atexitmodule.c (GH-23770) (diff) | |
download | cpython-357704c9f2375f29ed5b3a93adac086fa714538d.tar.gz cpython-357704c9f2375f29ed5b3a93adac086fa714538d.tar.bz2 cpython-357704c9f2375f29ed5b3a93adac086fa714538d.zip |
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.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pycore_interp.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_pylifecycle.h | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h index 2515234708..12416c2e94 100644 --- a/Include/internal/pycore_interp.h +++ b/Include/internal/pycore_interp.h @@ -233,8 +233,8 @@ struct _is { PyObject *after_forkers_parent; PyObject *after_forkers_child; #endif + /* AtExit module */ - void (*atexit_func)(PyObject *); PyObject *atexit_module; uint64_t tstate_next_unique_id; diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h index b691e63257..e6e4187cd5 100644 --- a/Include/internal/pycore_pylifecycle.h +++ b/Include/internal/pycore_pylifecycle.h @@ -109,6 +109,8 @@ PyAPI_FUNC(void) _PyErr_Display(PyObject *file, PyObject *exception, PyAPI_FUNC(void) _PyThreadState_DeleteCurrent(PyThreadState *tstate); +extern void _PyAtExit_Call(PyObject *module); + #ifdef __cplusplus } #endif |