[3.15] gh-109503: Fix document for shutil.move() on usage of os.rename() since it's inaccurate (GH-109507)#150611
Merged
serhiy-storchaka merged 1 commit intoJun 9, 2026
Conversation
…() since it's inaccurate (pythonGH-109507) Nonatomic move might be used even if the files are on the same filesystem in some cases. (cherry picked from commit 6ecd197) Co-authored-by: Fang Li <fangli@users.noreply.github.com>
Member
Contributor
|
Signed CLA again, you may proceed. @StanFromIreland thanks for following up. |
hugovk
reviewed
Jun 2, 2026
| of *src* will be created as the destination and *src* will be removed. | ||
| :func:`os.rename` is preferably used internally when *src* and the destination are on | ||
| the same filesystem. In case :func:`os.rename` fails due to :exc:`OSError` | ||
| (e.g. the user has write permission to the destination file but not to its parent |
Member
There was a problem hiding this comment.
Avoid Latin abbreviations: https://devguide.python.org/documentation/style-guide/#use-simple-language
Suggested change
| (e.g. the user has write permission to the destination file but not to its parent | |
| (for example, the user has write permission to the destination file but not to its parent |
| recreated under the new name if os.rename() fails because of cross | ||
| filesystem renames. | ||
| os.rename() is preferably used if the source and destination are on the | ||
| same filesystem. In case os.rename() fails due to OSError (e.g. the user |
Member
There was a problem hiding this comment.
Suggested change
| same filesystem. In case os.rename() fails due to OSError (e.g. the user | |
| same filesystem. In case os.rename() fails due to OSError (for example, the user |
Member
|
@hugovk, this is a backport PR. Sure we want to keep it consistent with main. |
Member
|
Okay, let's also fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nonatomic move might be used even if the files are
on the same filesystem in some cases.
(cherry picked from commit 6ecd197)
Co-authored-by: Fang Li fangli@users.noreply.github.com
shutil.movein case src/target are on the same filesystem #109503