Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5116f90

Browse files
committed
On David Ascher's recommendation: reversed order of 'utime()' and
'chmod()' in 'copy_file()'.
1 parent a8d0f4f commit 5116f90

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/distutils/util.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,13 @@ def copy_file (src, dst,
198198
_copy_file_contents (src, dst)
199199
if preserve_mode or preserve_times:
200200
st = os.stat (src)
201-
if preserve_mode:
202-
os.chmod (dst, S_IMODE (st[ST_MODE]))
201+
202+
# According to David Ascher <[email protected]>, utime() should be done
203+
# before chmod() (at least under NT).
203204
if preserve_times:
204205
os.utime (dst, (st[ST_ATIME], st[ST_MTIME]))
206+
if preserve_mode:
207+
os.chmod (dst, S_IMODE (st[ST_MODE]))
205208

206209
return 1
207210

0 commit comments

Comments
 (0)