diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 1eed23a..4acf56a 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 chosen name + # already exists on windows. + if _os.name == 'nt': + continue + else: + raise raise FileExistsError(_errno.EEXIST, "No usable temporary file name found")