https://github.com/python/cpython/commit/e57cf1c0ebdbf46adcf899eb2c3555e9124e4032 commit: e57cf1c0ebdbf46adcf899eb2c3555e9124e4032 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: vstinner <[email protected]> date: 2026-01-06T17:14:42Z summary:
[3.13] gh-142302: Fix mkstemp() documentation: clarify file descriptor inheritance behavior (GH-142338) (#143487) gh-142302: Fix mkstemp() documentation: clarify file descriptor inheritance behavior (GH-142338) The documentation incorrectly stated that the file descriptor is not inherited by child processes. In reality, the close-on-exec flag (when available) only prevents inheritance across exec() calls, not fork(). (cherry picked from commit e79c9b703117d8b0e7c4d86b704e2e7f120db883) Co-authored-by: ADITYA RAI <[email protected]> Co-authored-by: Victor Stinner <[email protected]> files: M Doc/library/os.rst M Doc/library/tempfile.rst diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 6603e58f441524..3685074a495fc4 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1889,7 +1889,8 @@ can be inherited by child processes. Since Python 3.4, file descriptors created by Python are non-inheritable by default. On UNIX, non-inheritable file descriptors are closed in child processes at the -execution of a new program, other file descriptors are inherited. +execution of a new program, other file descriptors are inherited. Note that +non-inheritable file descriptors are still *inherited* by child processes on :func:`os.fork`. On Windows, non-inheritable handles and file descriptors are closed in child processes, except for standard streams (file descriptors 0, 1 and 2: stdin, stdout diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index f0a81a093b435b..9d26f47820b134 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -225,8 +225,9 @@ The module defines the following user-callable items: properly implements the :const:`os.O_EXCL` flag for :func:`os.open`. The file is readable and writable only by the creating user ID. If the platform uses permission bits to indicate whether a file is executable, - the file is executable by no one. The file descriptor is not inherited - by child processes. + the file is executable by no one. + + The file descriptor is :ref:`not inherited by child processes <fd_inheritance>`. Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible for deleting the temporary file when done with it. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
