On Mon, Aug 26, 2013, at 7:42, Kim Gräsman wrote:
I wouldn't switch to using os.rmdir, however -- if the path names an actual directory rather than a symlink or a junction point, os.rmdir will delete it, whereas os.unlink will fail with access denied (as I believe it should.)
Only if it's empty. You could at least replace whatever your _delete_junction_point function is with it.
While we're on the subject of os.remove, can someone explain to me why it doesn't work on directories in Unix? [...]
I have nothing to offer here, sorry. It seems a little dangerous to muck about with the details of os file management, there must be millions of lines of code relying on the current behavior in one way or another.
I just don't like the fact that it's called "remove" but doesn't behave the same as the remove function from POSIX. Of course, remove/_wremove do not remove directories on Windows, and I've found evidence that this was true for some early Unixes as well. And the fact that windows unlink() allows you to remove some (but not all) things that windows considers to be directories is already violating the principle of being thin wrappers around system calls.