From ac0ad33c9a8e2103ed5b909b2250c9f314b8a288 Mon Sep 17 00:00:00 2001 From: Max Chernoff Date: Mon, 4 May 2026 21:50:22 -0600 Subject: [PATCH] gh-149394: Document that atexit functions are not called when os.exec*() is called Running the following test file #!/usr/bin/env python3 import atexit import os import sys atexit.register(print, "atexit callback called") # sys.exit() os.execl("/usr/bin/true", "true") does _not_ print a message to the console in Python 3.14, so add os.exec*() to the list of cases where atexit functions are not called. Fixes #149394. --- Doc/library/atexit.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/atexit.rst b/Doc/library/atexit.rst index b5caf5502d0e1c..c2ffe69259a6ad 100644 --- a/Doc/library/atexit.rst +++ b/Doc/library/atexit.rst @@ -15,7 +15,8 @@ at interpreter termination time they will be run in the order ``C``, ``B``, **Note:** The functions registered via this module are not called when the program is killed by a signal not handled by Python, when a Python fatal -internal error is detected, or when :func:`os._exit` is called. +internal error is detected, or when :func:`os._exit` or :func:`os.exec\* +` are called. **Note:** The effect of registering or unregistering functions from within a cleanup function is undefined.