diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py index 7aedc1c6df8..9a299dfd839 100644 --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -198,10 +198,13 @@ def copy_file (src, dst, _copy_file_contents (src, dst) if preserve_mode or preserve_times: st = os.stat (src) - if preserve_mode: - os.chmod (dst, S_IMODE (st[ST_MODE])) + + # According to David Ascher , utime() should be done + # before chmod() (at least under NT). if preserve_times: os.utime (dst, (st[ST_ATIME], st[ST_MTIME])) + if preserve_mode: + os.chmod (dst, S_IMODE (st[ST_MODE])) return 1