cpython: 1ea8b7233fd7 (original) (raw)

Mercurial > cpython

changeset 74288:1ea8b7233fd7

Issue #9993: When the source and destination are on different filesystems, and the source is a symlink, shutil.move() now recreates a symlink on the destination instead of copying the file contents. Patch by Jonathan Niehof and Hynek Schlawack. [#9993]

Antoine Pitrou solipsis@pitrou.net
date Fri, 06 Jan 2012 20:16:19 +0100
parents a4c19a946a5d
children 9f0728521731
files Doc/library/shutil.rst Lib/shutil.py Lib/test/test_shutil.py Misc/ACKS Misc/NEWS
diffstat 5 files changed, 64 insertions(+), 3 deletions(-)[+] [-] Doc/library/shutil.rst 7 Lib/shutil.py 11 Lib/test/test_shutil.py 43 Misc/ACKS 1 Misc/NEWS 5

line wrap: on

line diff

--- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -196,7 +196,12 @@ Directory and files operations If the destination is on the current filesystem, then :func:os.rename is used. Otherwise, src is copied (using :func:copy2) to dst and then

.. function:: disk_usage(path)

--- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -356,7 +356,10 @@ def move(src, dst): overwritten depending on os.rename() semantics. If the destination is on our current filesystem, then rename() is used.

+ A lot more could be done here... A look at a mv.c shows a lot of the issues this implementation glosses over. @@ -375,7 +378,11 @@ def move(src, dst): try: os.rename(src, real_dst) except OSError:

--- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1104,6 +1104,49 @@ class TestMove(unittest.TestCase): finally: shutil.rmtree(TESTFN, ignore_errors=True)

+

+

+

+ class TestCopyFile(unittest.TestCase):

--- a/Misc/ACKS +++ b/Misc/ACKS @@ -707,6 +707,7 @@ Max Neunhöffer George Neville-Neil Johannes Nicolai Samuel Nicolary +Jonathan Niehof Gustavo Niemeyer Oscar Nierstrasz Hrvoje Niksic

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -422,6 +422,11 @@ Core and Builtins Library ------- +- Issue #9993: When the source and destination are on different filesystems,