eryksun added the comment: Shouldn't it be checking whether `file` (or `filename`) is a directory [1]? For example:
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(file): continue # If the directory allows write access, continue # trying names. On Windows, currently this test # doesn't work. The implementation assumes all # directories allow write access, but it really # depends on the directory's discretionary and # system access control lists (DACL & SACL). elif _os.access(dir, _os.W_OK): continue else: raise --- [1]: Windows sets the last error to ERROR_ACCESS_DENIED when a system call returns the NTSTATUS code STATUS_FILE_IS_A_DIRECTORY. This status code is returned by NtCreateFile and NtOpenFile when the target file is a directory, but the caller asked for anything but a directory (i.e. CreateOptions contains FILE_NON_DIRECTORY_FILE). ---------- nosy: +eryksun _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22107> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com