classification
Title: shutil.copystat() may fail...
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 3.0, Python 2.6
process
Status: open Resolution:
Dependencies: shutil.copytree doesn't preserve directory permissions
View: 1666318
Superseder:
Assigned To: Nosy List: prikryl, thomaswaldmann (2)
Priority: normal Keywords

Created on 2005-02-21 09:02 by prikryl, last changed 2009-03-20 21:43 by ajaksu2.

Files
File name Uploaded Description Edit Remove
shutil_copystat_failure.zip prikryl, 2005-02-21 09:02 simple test
Messages (2)
msg24358 - (view) Author: Petr Prikryl (prikryl) Date: 2005-02-21 09:02
Hi,

The shutil.copystat() may fail in case when the 
destination file has read-only attribute. It's because the 
implementation calls the os.utime() first and os.chmod() 
later. In Windows (I am not sure if also in Unix-based 
system), the os.utime() fails for read-only files. 

The implementation should ensure the read/write access 
by " try: os.chmod(dst, 0600)..." before calling the 
os.utime(). The file mode will be copied from the source 
file in the next step anyway. The simplistic test 
attached (Unix line ending used inside the tst.py zipped 
inside).

Petr
msg24359 - (view) Author: Thomas Waldmann (thomaswaldmann) Date: 2007-03-24 19:06
See http://sourceforge.net/tracker/index.php?func=detail&aid=1666318&group_id=5470&atid=105470 for another problem with utime() on win32/nt with directories.

History
Date User Action Args
2009-03-20 21:43:50ajaksu2setdependencies: + shutil.copytree doesn't preserve directory permissions
type: behavior
stage: test needed
versions: + Python 2.6, Python 3.0, - Python 2.4
2005-02-21 09:02:55prikrylcreate