-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Description
The documentation about os.rename https://docs.python.org/3/library/os.html#os.rename says the following about Unix:
If successful, the renaming will be an atomic operation (this is a POSIX requirement).
But this sentence is misleading. The rename call is atomic only in that the new filename (given by the dst parameter) will always point to either the old file or new file, with no intermediate state. In particular, if you replace an existing file name, then there won't be an observable state when that file name appears deleted. The rename does not act atomically on the old and new filenames together, as in it may happen that both the old name and new name could point to the same file at the same time. I don't think there was ever a requirement for rename to be atomic in the latter sense.
I'm not sure what the best phrasing for the documentation would be. Perhaps something like this:
The new filename dst is updated atomically (this is a POSIX requirement).
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status