You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inaccurate and misleading document for shutil.move in case src/target are on the same filesystem #109503
If the destination is on the current filesystem, then :func:os.rename is used.
Otherwise, src is copied to dst using copy_function and then removed.
which seems to be incorrect. The actual behavior shows below:
If src and target are on the same filesystem, os.rename is preferred, which is an atomic operation.
But, if os.rename fails due to some reason (e.g. permission denied), then shutil.move will silently fallback to nonatomiccopy+remove.
This fallback behavior is crucial in case atomic operation matters. It creates false statement that an operation must be atomic, while in fact is non-atomic in some cases.
# Run by userAshutil.move('/dirSrc/fileSrc', '/dirTarget/fileTarget')
# Move succeeded
Based on current doc, user expects that the move must be atomic since both files are on the same filesystem. But in fact, this operation will fall back to copy+del silently, which is not atomic.
changed the title [-]Inaccurate and misleading documentation for `shutil.move` in case src/target on the same filesystem[/-][+]Inaccurate and misleading document for `shutil.move` in case src/target on the same filesystem[/+]on Sep 17, 2023
changed the title [-]Inaccurate and misleading document for `shutil.move` in case src/target on the same filesystem[/-][+]Inaccurate and misleading document for `shutil.move` in case src/target are on the same filesystem[/+]on Sep 17, 2023
Activity
pythongh-109503: fix doc for shutil.move on usage of os.rename
[-]Inaccurate and misleading documentation for `shutil.move` in case src/target on the same filesystem[/-][+]Inaccurate and misleading document for `shutil.move` in case src/target on the same filesystem[/+][-]Inaccurate and misleading document for `shutil.move` in case src/target on the same filesystem[/-][+]Inaccurate and misleading document for `shutil.move` in case src/target are on the same filesystem[/+]pythongh-109503: fix doc for shutil.move on usage of os.rename
pythongh-109503: fix doc for shutil.move on usage of os.rename
pythongh-109503: fix doc for shutil.move on usage of os.rename
pythongh-109503: fix doc for shutil.move on usage of os.rename
pythongh-109503: fix doc for shutil.move on usage of os.rename
pythongh-109503: fix doc for shutil.move on usage of os.rename
pythongh-109503: fix doc for shutil.move on usage of os.rename
gh-109503: Fix document for shutil.move() on usage of os.rename() sin…
[3.15] gh-109503: Fix document for shutil.move() on usage of os.renam…
[3.14] gh-109503: Fix document for shutil.move() on usage of os.renam…
[3.13] gh-109503: Fix document for shutil.move() on usage of os.renam…