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:
Victor Stinner 2020-12-14 23:07:54 +01:00 committed by GitHub
parent 83d52044ae
commit 357704c9f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 53 additions and 28 deletions

View file

@ -854,8 +854,6 @@ class PyBuildExt(build_ext):
# C-optimized pickle replacement
self.add(Extension("_pickle", ["_pickle.c"],
extra_compile_args=['-DPy_BUILD_CORE_MODULE']))
# atexit
self.add(Extension("atexit", ["atexitmodule.c"]))
# _json speedups
self.add(Extension("_json", ["_json.c"],
extra_compile_args=['-DPy_BUILD_CORE_MODULE']))