Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b9a76e2

Browse files
author
Charles-François Natali
committed
Issue #16860: In tempfile, use O_CLOEXEC when available to set the
close-on-exec flag atomically.
1 parent 4e02538 commit b9a76e2

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

Lib/tempfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def _set_cloexec(fd):
5757
_allocate_lock = _thread.allocate_lock
5858

5959
_text_openflags = _os.O_RDWR | _os.O_CREAT | _os.O_EXCL
60+
if hasattr(_os, 'O_CLOEXEC'):
61+
_text_openflags |= _os.O_CLOEXEC
6062
if hasattr(_os, 'O_NOINHERIT'):
6163
_text_openflags |= _os.O_NOINHERIT
6264
if hasattr(_os, 'O_NOFOLLOW'):

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ Core and Builtins
204204
Library
205205
-------
206206

207+
- Issue #16860: In tempfile, use O_CLOEXEC when available to set the
208+
close-on-exec flag atomically.
209+
207210
- Issue #16674: random.getrandbits() is now 20-40% faster for small integers.
208211

209212
- Issue #16009: JSON error messages now provide more information.

0 commit comments

Comments
 (0)