diff options
author | Eli Bendersky <eliben@gmail.com> | 2013-09-06 13:11:19 (GMT) |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2013-09-06 13:11:19 (GMT) |
commit | f315df31bd8a927768bb94c3342d155cdc87d997 (patch) | |
tree | 25a027aa12346e1fff608ea693a61ff3b2cd2aa2 /Lib/tempfile.py | |
parent | 43c6ef189955474001aad75d3b47d895180b2d42 (diff) | |
download | cpython-f315df31bd8a927768bb94c3342d155cdc87d997.zip cpython-f315df31bd8a927768bb94c3342d155cdc87d997.tar.gz cpython-f315df31bd8a927768bb94c3342d155cdc87d997.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.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 8a165ed..91332b6 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -219,6 +219,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") |