mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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.
This commit is contained in:
parent
43c6ef1899
commit
f315df31bd
4 changed files with 38 additions and 0 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue