@@ -86,6 +86,7 @@ Summary -- Release highlights
8686* :pep: `782 `: :ref: `A new PyBytesWriter C API to create a Python bytes object
8787 <whatsnew315-pybyteswriter>`
8888* :pep: `803 `: :ref: `Stable ABI for Free-Threaded Builds <whatsnew315-abi3t >`
89+ * :pep: `788 `: :ref: `Protection against finalization in the C API <whatsnew315-c-api-interpreter-finalization >`
8990* :ref: `The JIT compiler has been significantly upgraded <whatsnew315-jit >`
9091* :ref: `Improved error messages <whatsnew315-improved-error-messages >`
9192* :ref: `The official Windows 64-bit binaries now use the tail-calling interpreter
@@ -446,6 +447,38 @@ If not using a build tool -- or when writing such a tool -- you can select
446447``abi3t `` by setting the macro :c:macro: `!Py_TARGET_ABI3T ` as discussed
447448in :ref: `abi3-compiling `.
448449
450+ .. _whatsnew315-c-api-interpreter-finalization :
451+
452+ :pep: `788 `: Protecting the C API from interpreter finalization
453+ --------------------------------------------------------------
454+
455+ In the C API, :term: `interpreter finalization <interpreter shutdown> ` can be
456+ problematic for many extensions, because :term: `attaching <attached thread
457+ state> ` a thread state will permanently hang the thread, resulting in deadlocks
458+ and other spurious issues. Additionally, it has historically been impossible
459+ to atomically check whether an interpreter is alive, leading to crashes
460+ when a thread concurrently deletes an interpreter while another thread is
461+ trying to attach to it.
462+
463+ There are now several new suites of APIs to circumvent these problems:
464+
465+ * :ref: `Interpreter guards <interpreter-views >`, which prevent an interpreter
466+ from finalizing.
467+ * :ref: `Interpreter views <interpreter-guards >`, which allow thread-safe access
468+ to an interpreter that may be concurrently finalizing or deleted.
469+ * :ref: `New APIs <c-api-attach-detach >` to automatically attach and detach
470+ thread states that come with built-in protection against finalization.
471+
472+ In addition, APIs in the ``PyGILState `` family (most notably
473+ :c:func: `PyGILState_Ensure ` and :c:func: `PyGILState_Release `) have been
474+ :term: `soft deprecated `. There is **no ** plan to remove them, and existing
475+ code will continue to work, but there will be no new ``PyGILState `` APIs
476+ in future versions of Python.
477+
478+ .. seealso :: :pep:`788` for further details.
479+
480+ (Contributed by Peter Bierma in :gh: `149101 `.)
481+
449482
450483.. _whatsnew315-improved-error-messages :
451484
0 commit comments