aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index cadb0bed3cc..53d14ff5c67 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -180,7 +180,7 @@ def _candidate_tempdir_list():
return dirlist
-def _get_default_tempdir():
+def _get_default_tempdir(dirlist=None):
"""Calculate the default directory to use for temporary files.
This routine should be called exactly once.
@@ -190,7 +190,8 @@ def _get_default_tempdir():
service, the name of the test file must be randomized."""
namer = _RandomNameSequence()
- dirlist = _candidate_tempdir_list()
+ if dirlist is None:
+ dirlist = _candidate_tempdir_list()
for dir in dirlist:
if dir != _os.curdir:
@@ -655,7 +656,7 @@ else:
fd = None
def opener(*args):
nonlocal fd
- flags2 = (flags | _os.O_TMPFILE) & ~_os.O_CREAT
+ flags2 = (flags | _os.O_TMPFILE) & ~_os.O_CREAT & ~_os.O_EXCL
fd = _os.open(dir, flags2, 0o600)
return fd
try: