[Python-checkins] bpo-4928: Document NamedTemporaryFile non-deletion after SIGKILL (#26198)
freddrake
webhook-mailer at python.org
Wed May 19 10:21:17 EDT 2021
https://github.com/python/cpython/commit/b3ab4344d11edd890916be3526b07362182fb172
commit: b3ab4344d11edd890916be3526b07362182fb172
branch: main
author: Catherine Devlin <catherine.devlin at gmail.com>
committer: freddrake <fred at fdrake.net>
date: 2021-05-19T10:21:03-04:00
summary:
bpo-4928: Document NamedTemporaryFile non-deletion after SIGKILL (#26198)
* 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>
files:
A Misc/NEWS.d/next/Library/2021-05-17-21-05-06.bpo-4928.Ot2yjO.rst
M Doc/library/tempfile.rst
M Lib/tempfile.py
diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst
index 2970252036780..49396b5f4bdc4 100644
--- a/Doc/library/tempfile.rst
+++ b/Doc/library/tempfile.rst
@@ -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
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index efcf7a7fb3bbc..8570c3ba0627f 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -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
index 0000000000000..359f801582154
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-05-17-21-05-06.bpo-4928.Ot2yjO.rst
@@ -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
More information about the Python-checkins
mailing list