classification
Title: shutil.copystat() may fail...
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: 1666318 Superseder:
Assigned To: tarek Nosy List: Neil Muller, prikryl, tarek, thomaswaldmann
Priority: normal Keywords:

Created on 2005-02-21 09:02 by prikryl, last changed 2016-04-28 04:44 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
shutil_copystat_failure.zip prikryl, 2005-02-21 09:02 simple test
Messages (4)
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.

msg180651 - (view) Author: Neil Muller (Neil Muller) Date: 2013-01-26 10:11
I can't reproduce this bug on windows XP or windows 7 with python 2.7 or python 3.3.

Is this still an issue?
msg180798 - (view) Author: Petr Prikryl (prikryl) Date: 2013-01-27 22:26
Well, it is quite an old event. Anyway, I have fixed the simple example, and launched it on Python 2.6, 2.7, 3.2, 3.3. It does not fail now. But I did not tested it heavily.

From my point of view, it was probably fixed.
History
Date User Action Args
2016-04-28 04:44:10berker.peksagsetstatus: open -> closed
resolution: accepted -> out of date
stage: test needed -> resolved
2013-01-27 22:26:46prikrylsetmessages: + msg180798
2013-01-26 10:11:57Neil Mullersetnosy: + Neil Muller
messages: + msg180651
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