classification
Title: shutil.copystat() may fail...
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution: accepted
Dependencies: shutil.copytree doesn't give control over directory permissions
View: 1666318
Superseder:
Assigned To: tarek Nosy List: prikryl, tarek, thomaswaldmann
Priority: normal Keywords:

Created on 2005-02-21 09:02 by prikryl, last changed 2010-08-21 12:11 by BreamoreBoy.

Files
File name Uploaded Description Edit
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
2010-08-21 12:11:21BreamoreBoysetversions: - Python 2.6, Python 3.3
2010-04-20 09:31:36tareksetassignee: tarek

resolution: accepted
nosy: + tarek
versions: + Python 3.1, Python 2.7, Python 3.2, Python 3.3, - Python 3.0
2009-03-20 21:43:50ajaksu2setdependencies: + shutil.copytree doesn't give control over directory permissions
type: behavior
stage: test needed
versions: + Python 2.6, Python 3.0, - Python 2.4
2005-02-21 09:02:55prikrylcreate