]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-4928: Document NamedTemporaryFile non-deletion after SIGKILL (#26198)
authorCatherine Devlin <catherine.devlin@gmail.com>
Wed, 19 May 2021 14:21:03 +0000 (10:21 -0400)
committerGitHub <noreply@github.com>
Wed, 19 May 2021 14:21:03 +0000 (10:21 -0400)
* bpo-4928 Document NamedTemporaryFile non-deletion after SIGKILL

* ðŸ“œðŸ¤– Added by blurb_it.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Doc/library/tempfile.rst
Lib/tempfile.py
Misc/NEWS.d/next/Library/2021-05-17-21-05-06.bpo-4928.Ot2yjO.rst [new file with mode: 0644]

index 2970252036780dae28e0db7c8388363fc265f6c0..49396b5f4bdc4d0ec07f589a2cf5db0a5a54494d 100644 (file)
@@ -87,6 +87,9 @@ The module defines the following user-callable items:
    attribute is the underlying true file object. This file-like object can
    be used in a :keyword:`with` statement, just like a normal file.
 
+   On POSIX (only), a process that is terminated abruptly with SIGKILL
+   cannot automatically delete any NamedTemporaryFiles it created.
+
    .. audit-event:: tempfile.mkstemp fullpath tempfile.NamedTemporaryFile
 
    .. versionchanged:: 3.8
index efcf7a7fb3bbc1968d56a911c752d7b0e3d7fc86..8570c3ba0627fa90c005b9d6b88c327f00559c58 100644 (file)
@@ -532,6 +532,10 @@ def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None,
     Returns an object with a file-like interface; the name of the file
     is accessible as its 'name' attribute.  The file will be automatically
     deleted when it is closed unless the 'delete' argument is set to False.
+
+    On POSIX, NamedTemporaryFiles cannot be automatically deleted if
+    the creating process is terminated abruptly with a SIGKILL signal.
+    Windows can delete the file even in this case.
     """
 
     prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
diff --git a/Misc/NEWS.d/next/Library/2021-05-17-21-05-06.bpo-4928.Ot2yjO.rst b/Misc/NEWS.d/next/Library/2021-05-17-21-05-06.bpo-4928.Ot2yjO.rst
new file mode 100644 (file)
index 0000000..359f801
--- /dev/null
@@ -0,0 +1 @@
+Documented existing behavior on POSIX: NamedTemporaryFiles are not deleted when creating process is killed with SIGKILL
\ No newline at end of file