[Python-Dev] os.utime and os.chmod failures (etc) Python 2.5b2

2006-07-20 Thread Michael Foord
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).

The source code snippet is :

if os.path.isdir(targetdir):
shutil.rmtree(targetdir)
shutil.copytree(thisentry, targetdir)

The code in shutil.py is :

def copystat(src, dst):
Copy all stat info (mode bits, atime and mtime) from src to dst
st = os.stat(src)
mode = stat.S_IMODE(st.st_mode)
if hasattr(os, 'utime'):
os.utime(dst, (st.st_atime, st.st_mtime))
if hasattr(os, 'chmod'):
os.chmod(dst, mode)


Additionally, after running a couple of times I get core dumps when 
trying to run the interactive interpreter. Oddly IDLE and other programs 
still run. However this is after installing py2exe, wxPython and pywin32 
(all of which have Python 2.5 builds), so there is possibly some weird 
interaction.

My install directory has the following three dlls in it :

MSVCIRT.dll
MSVCP60.dll
MSVCRT.dll

It has none of the msvc7 dlls that I would expect.

I'm now at work and so don't have time to experiment, but tonight I will 
try uninstalling all my Python 2.5 stuff and re-installing just 2.5b2. I 
will see what dlls are present, run the interpreter a few times, and 
test a simple script with shutil.copytree.

All the best,


Michael Foord
http://www.voidspace.org.uk/python/index.shtml
___
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


Re: [Python-Dev] os.utime and os.chmod failures (etc) Python 2.5b2

2006-07-20 Thread Thomas Heller
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


Re: [Python-Dev] os.utime and os.chmod failures (etc) Python 2.5b2

2006-07-20 Thread Michael Foord
Thomas Heller wrote:
 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.
   
Ok, thanks.

Michael
http://www.voidspace.org.uk/python/index.shtml

 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/fuzzyman%40voidspace.org.uk

   

___
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