Issue 12577: Misleading shutil.move docs regarding when os.rename is used (original) (raw)

Issue12577

Created on 2011-07-17 08:59 by catalin.iacob, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
clarify-shutil.move-docs.patch catalin.iacob,2011-07-17 09:00 review
Messages (5)
msg140520 - (view) Author: Catalin Iacob (catalin.iacob) * Date: 2011-07-17 08:59
I recently tried to answer the question: "When moving a file to a destination that is an already existing file, is the destination overwritten?" From the current docs I understood that if src and dst are on the same filesystem then os.rename is used, if they are on different filesystems then copy + remove is used instead. Since os.rename fails on Windows if the destination exists I concluded that shutil.move would fail on Windows and overwrite dst on Unix.
msg140521 - (view) Author: Catalin Iacob (catalin.iacob) * Date: 2011-07-17 09:00
Attached patch which clarifies that the copy fallback is used whenever os.rename fails not just for the different filesystems case.
msg140543 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-07-17 22:33
Should information on Windows behavior, which you experienced be included too? How about - It uses :func:`os.rename` to perform the move. If that fails, for example because src and dst are on different filesystems or in case of Windows where rename cannot be done if dst exists, fallback to copying src (with :func:`copy2`) to the dst and then removing src.
msg140567 - (view) Author: Catalin Iacob (catalin.iacob) * Date: 2011-07-18 08:27
Senthil's proposal in has +1 from me.
msg140636 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-07-19 00:06
New changeset 62048a6eb43c by Senthil Kumaran in branch '3.2': Fix closes - clarify shutil.move documentation. Patch suggestion by Catalin Iacob http://hg.python.org/cpython/rev/62048a6eb43c New changeset 912b97ee40a7 by Senthil Kumaran in branch 'default': merge from 3.2 - Fix closes - clarify shutil.move documentation. Patch suggestion by Catalin Iacob http://hg.python.org/cpython/rev/912b97ee40a7 New changeset 33f09733612e by Senthil Kumaran in branch '2.7': merge from 3.2 - Fix closes - clarify shutil.move documentation. Patch suggestion by Catalin Iacob http://hg.python.org/cpython/rev/33f09733612e
History
Date User Action Args
2022-04-11 14:57:19 admin set github: 56786
2011-07-19 00:06:05 python-dev set status: open -> closednosy: + python-devmessages: + resolution: fixedstage: resolved
2011-07-18 08:27:11 catalin.iacob set messages: +
2011-07-17 22:33:48 orsenthil set nosy: + orsenthilmessages: +
2011-07-17 09:00:13 catalin.iacob set files: + clarify-shutil.move-docs.patchkeywords: + patchmessages: +
2011-07-17 08:59:21 catalin.iacob create