]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-142302: Fix mkstemp() documentation: clarify file descriptor inheritance...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 6 Jan 2026 17:14:12 +0000 (18:14 +0100)
committerGitHub <noreply@github.com>
Tue, 6 Jan 2026 17:14:12 +0000 (17:14 +0000)
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 <adi.hack1234@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Doc/library/os.rst
Doc/library/tempfile.rst

index 35585481d75ae3e2ac83b320755754e38f81263c..a2d1936c45c0a7678a89bc4a89784b379e88f5a5 100644 (file)
@@ -1961,7 +1961,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
index f0a81a093b435b64aa78cf868f1399f4b14a0ce2..9d26f47820b1341757864ce28daad0449014236e 100644 (file)
@@ -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.