diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 6146235..5777a53 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -220,7 +220,7 @@ def _get_default_tempdir(): except PermissionError: # This exception is thrown when a directory with the chosen name # already exists on windows. - if (_os.name == 'nt' and _os.path.isdir(dir) and + if (_os.name == 'nt' and _os.path.isdir(filename) and _os.access(dir, _os.W_OK)): continue break # no point trying more names in this directory @@ -263,7 +263,7 @@ def _mkstemp_inner(dir, pre, suf, flags, output_type): except PermissionError: # This exception is thrown when a directory with the chosen name # already exists on windows. - if (_os.name == 'nt' and _os.path.isdir(dir) and + if (_os.name == 'nt' and _os.path.isdir(file) and _os.access(dir, _os.W_OK)): continue else: @@ -368,14 +368,6 @@ def mkdtemp(suffix=None, prefix=None, dir=None): _os.mkdir(file, 0o700) 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' and _os.path.isdir(dir) and - _os.access(dir, _os.W_OK)): - continue - else: - raise return file raise FileExistsError(_errno.EEXIST,