-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-98240: Updated Path.rename docs, when it is atomic #98245
Conversation
Doc/library/pathlib.rst
Outdated
it will be replaced silently if the user has permission. | ||
it will be replaced silently if the user has permission. The operation may | ||
fail on some Unix flavors if *src* and *dst* are on different filesystems. | ||
If successful, the renaming will be an atomic operation (this is a POSIX requirement). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these two lines only apply to Unix? If so, I would phrase similar to the Windows specific line below.
A
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know, what happens on Windows. I have checked, that Path.rename
is implemented with os.rename
and checked its documentation. So, I believe, that this line is POSIX specific. I have copied it from `os.rename' docs. Should it be written:
On Unix, if successful, the renaming will be an atomic operation (this is a POSIX requirement).
Should I change it in `os.rename' docs also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to make promises that are not consistent across OSs which we will be expected to keep.
Doc/library/pathlib.rst
Outdated
it will be replaced silently if the user has permission. | ||
it will be replaced silently if the user has permission. The operation may | ||
fail on some Unix flavors if *src* and *dst* are on different filesystems. | ||
If successful, the renaming will be an atomic operation (this is a POSIX requirement). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to make this promise as part of the API as there is no explicit guarantee the OS is POSIX-compliant.
If successful, the renaming will be an atomic operation (this is a POSIX requirement). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, in order to create a file in an atomic way, do I have to use os.rename
(which is used in Path.rename
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point as os.rename()
makes that promise. 🤔 I guess it's a question of whether we think it's reasonable to assume we will rely on os.rename()
going forward. At which point it might sense to link to the os.rename()
docs and say those guarantees hold rather than duplicate them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have linked it (and deleted my previous commit).
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I don't like copying the docs of |
I have changed PR to point to |
I have made the requested changes; please review again |
Thanks for making the requested changes! @brettcannon: please review the changes made to this pull request. |
Thanks @mateka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10. |
Thanks @mateka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
GH-101414 is a backport of this pull request to the 3.10 branch. |
GH-101415 is a backport of this pull request to the 3.11 branch. |
Automerge-Triggered-By: GH:brettcannon