homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Misleading shutil.move docs regarding when os.rename is used
Type: Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: catalin.iacob, docs@python, orsenthil, python-dev
Priority: normal Keywords: patch

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 msg140543 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 issue12577 - 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 issue12577 - 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 issue12577 - 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:19adminsetgithub: 56786
2011年07月19日 00:06:05python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg140636

resolution: fixed
stage: resolved
2011年07月18日 08:27:11catalin.iacobsetmessages: + msg140567
2011年07月17日 22:33:48orsenthilsetnosy: + orsenthil
messages: + msg140543
2011年07月17日 09:00:13catalin.iacobsetfiles: + clarify-shutil.move-docs.patch
keywords: + patch
messages: + msg140521
2011年07月17日 08:59:21catalin.iacobcreate

AltStyle によって変換されたページ (->オリジナル) /