summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2013-09-06 13:14:16 (GMT)
committerEli Bendersky <eliben@gmail.com>2013-09-06 13:14:16 (GMT)
commit309836c5c8a7bf85c666ff913bf903b8f735cfa5 (patch)
tree636eea90d5158dec50db0080fe4d9110039c3648 /Lib/tempfile.py
parentf7b436ce8d69e1067cf2cb3769de93605b307327 (diff)
parentf315df31bd8a927768bb94c3342d155cdc87d997 (diff)
downloadcpython-309836c5c8a7bf85c666ff913bf903b8f735cfa5.zip
cpython-309836c5c8a7bf85c666ff913bf903b8f735cfa5.tar.gz
cpython-309836c5c8a7bf85c666ff913bf903b8f735cfa5.tar.bz2
Issue #18849: Fixed a Windows-specific tempfile bug where collision with an
existing directory caused mkstemp and related APIs to fail instead of retrying. Report and fix by Vlad Shcherbina.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 1eed23a..7da71c8 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -199,6 +199,13 @@ def _mkstemp_inner(dir, pre, suf, flags):
return (fd, _os.path.abspath(file))
except FileExistsError:
continue # try again
+ except PermissionError:
+ # This exception is thrown when a directory with the chosen name
+ # already exists on windows.
+ if _os.name == 'nt':
+ continue
+ else:
+ raise
raise FileExistsError(_errno.EEXIST,
"No usable temporary file name found")