diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index 29702520367..49396b5f4bd 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 efcf7a7fb3b..8570c3ba062 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 00000000000..359f8015821 --- /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