Michael Foord schrieb:
> Hello all,
> 
> There may be a reasonable cause for this (i.e. it is likely to be my 
> fault) - but it is consistent across two different machines I have tried 
> it on.
> 
> With Python 2.5b2 (from the msi at Python.org), running on Windows XP 
> Pro SP2,  ``os.utime`` and ``os.chmod`` fail with WindowsError. The same 
> code runs fine on Python 2.3 and Python 2.4.
> 
> [err]     shutil.copytree(thisentry, targetdir)
> [err]   File "C:\Python25\lib\shutil.py", line 130, in copytree
> [err]     copystat(src, dst)
> [err]   File "C:\Python25\lib\shutil.py", line 67, in copystat
> [err]     os.utime(dst, (st.st_atime, st.st_mtime))
> [err] WindowsError: [Error 13] Access is denied: 'lib\\Pmw'
> [err]
> 
> The script uses ``shutil.copytree`` to copy a directory (using relative 
> paths).

IMO this is a bug in Python 2.5, on Windows.
The problem is that the call to 'copystat(src, dst)' was added to
the shutil.copytree function, in svn r38363 probably.  It will fail
always on Windows, since os.utime does not work on directories (as the
docs correctly explain).

I guess that a patch similar to this one should fix it:

Index: shutil.py
===================================================================
--- shutil.py   (Revision 50710)
+++ shutil.py   (Arbeitskopie)
@@ -127,7 +127,12 @@
         # continue with other files
         except Error, err:
             errors.extend(err.args[0])
-    copystat(src, dst)
+    try:
+        copystat(src, dst)
+    except WindowsError:
+        pass
+    except OSError, err:
+        errors.extend(err.args[0])
     if errors:
         raise Error, errors
 
But you should report this to the bug tracker.

Thomas

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to