Skip to content

Commit b3ab434

Browse files
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>
1 parent 5d6e463 commit b3ab434

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

Doc/library/tempfile.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ The module defines the following user-callable items:
8787
attribute is the underlying true file object. This file-like object can
8888
be used in a :keyword:`with` statement, just like a normal file.
8989

90+
On POSIX (only), a process that is terminated abruptly with SIGKILL
91+
cannot automatically delete any NamedTemporaryFiles it created.
92+
9093
.. audit-event:: tempfile.mkstemp fullpath tempfile.NamedTemporaryFile
9194

9295
.. versionchanged:: 3.8

Lib/tempfile.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,10 @@ def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None,
532532
Returns an object with a file-like interface; the name of the file
533533
is accessible as its 'name' attribute. The file will be automatically
534534
deleted when it is closed unless the 'delete' argument is set to False.
535+
536+
On POSIX, NamedTemporaryFiles cannot be automatically deleted if
537+
the creating process is terminated abruptly with a SIGKILL signal.
538+
Windows can delete the file even in this case.
535539
"""
536540

537541
prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Documented existing behavior on POSIX: NamedTemporaryFiles are not deleted when creating process is killed with SIGKILL

0 commit comments

Comments
 (0)