[ python-Bugs-1048878 ] shutil.copytree copies stat of files,
but not of dirs
SourceForge.net
noreply at sourceforge.net
Sat Jan 8 13:32:52 CET 2005
Bugs item #1048878, was opened at 2004-10-18 00:12
Message generated for change (Comment added) made by jlgijsbers
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1048878&group_id=5470
Category: Python Library
Group: Python 2.4
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Thomas Waldmann (thomaswaldmann)
>Assigned to: Johannes Gijsbers (jlgijsbers)
Summary: shutil.copytree copies stat of files, but not of dirs
Initial Comment:
Caring for stat of files, but modifying stat of dirs is
maybe not what's expected from that function.
I discovered that when implementing a new function in
MoinMoin when it changed directory modes from
-rw-rw---- to -rw-------.
It is easy to fix:
$ diff -u shutil.py shutil.py-tw
--- shutil.py 2004-10-17 23:19:25.000000000 +0200
+++ shutil.py-tw 2004-10-18 00:01:57.000000000 +0200
@@ -109,6 +109,7 @@
"""
names = os.listdir(src)
os.mkdir(dst)
+ copystat(src, dst)
errors = []
for name in names:
srcname = os.path.join(src, name)
Maybe it is even better to do that copystat after the
for loop (and thus, after the recursive calls modifying
the timestamp of the directory) and before the if
statement, so it may even conserve the dir timestamp (I
didn't test that).
It happens in 2.3.4 as well as in 2.4 beta 1.
Strictly taken, it is not a bug, as the docs say
nothing about what it does to directories. But well,
maybe just the docs need to be changed as well. :)
----------------------------------------------------------------------
>Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2005-01-08 13:32
Message:
Logged In: YES
user_id=469548
Fixed by applying patch #1094015.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1048878&group_id=5470
More information about the Python-bugs-list
mailing list