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: shutil.copytree copies stat of files, but not of dirs
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jlgijsbers Nosy List: jlgijsbers, thomaswaldmann
Priority: normal Keywords:

Created on 2004-10-17 22:12 by thomaswaldmann, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg22749 - (view) Author: Thomas Waldmann (thomaswaldmann) Date: 2004-10-17 22:12
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. :)
msg22750 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2005-01-08 12:32
Logged In: YES 
user_id=469548

Fixed by applying patch #1094015.
History
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 41040
2004-10-17 22:12:52thomaswaldmanncreate