Skip to content

Commit 97c3d25

Browse files
committed
gh-136156: Allow using linkat() with TemporaryFile
tempfile.TemporaryFile() no longer uses os.O_EXCL with os.O_TMPFILE, so it's possible to use linkat() on the file descriptor.
1 parent 8ac7613 commit 97c3d25

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/tempfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ def TemporaryFile(mode='w+b', buffering=-1, encoding=None,
656656
fd = None
657657
def opener(*args):
658658
nonlocal fd
659-
flags2 = (flags | _os.O_TMPFILE) & ~_os.O_CREAT
659+
flags2 = (flags | _os.O_TMPFILE) & ~_os.O_CREAT & ~_os.O_EXCL
660660
fd = _os.open(dir, flags2, 0o600)
661661
return fd
662662
try:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:func:`tempfile.TemporaryFile` no longer uses :data:`os.O_EXCL` with
2+
:data:`os.O_TMPFILE`, so it's possible to use ``linkat()`` on the file
3+
descriptor. Patch by Victor Stinner.

0 commit comments

Comments
 (0)