diff options
author | Victor Stinner <vstinner@python.org> | 2020-12-14 22:07:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 22:07:54 (GMT) |
commit | 357704c9f2375f29ed5b3a93adac086fa714538d (patch) | |
tree | 8b69403f419da52a6728c8557e1169aaf23c9e2e /Python | |
parent | 83d52044ae4def1e8611a4b1b9263b850ca5c458 (diff) | |
download | cpython-357704c9f2375f29ed5b3a93adac086fa714538d.zip cpython-357704c9f2375f29ed5b3a93adac086fa714538d.tar.gz cpython-357704c9f2375f29ed5b3a93adac086fa714538d.tar.bz2 |
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 'Python')
-rw-r--r-- | Python/pylifecycle.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 54a35a2..7b80d01 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -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 |