You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When copying a file with shutil.copy2() between two ext4 filesystems on 64-bit Linux, the mtime of the destination file is different after the copy. It appears as if the resolution is slightly different, so the mtime is truncated slightly. For example:
This is a system limitation. The underlying file system supports nanosecond resolution for the file stamps, and stat(2) also supports reporting them. However, utimes(2) only supports microsecond resolution when setting them.
Linux supports utimensat(2) since 2.6.22 (July 2007), however, Python doesn't use it. It would be possible to come up with a patch to transparently use it where available. Are you interested in writing such a patch?
As a consequential issue: For Python, a long time ago, it was decided that time stamps in system interfaces are floating point numbers. As a consequence, nanoseconds cannot be accurately represented for today's dates (IIUC). I doubt there is anything we could do about this; this is likely "won't fix".
peterjc commented on Jan 28, 2011
peterjcmannequin
Mannequin
More actions
I'm also seeing this on 32bit Windows XP using Python 3.1.2, and Python 3.2rc1 on a local NTFS filesystem.
e.g. from os.stat(filename).st_mtime after using shutil.copy2(...)
I've been using shutil.copy2 then expecting st_mtime will be equal (or at least that the copy file will be newer than the original). As you can see in this case, the copy is sometimes a fraction older.
The same issue occurs using shutil.copy then shutils.copystat (probably not a surprise).
Arfrever commented on Apr 27, 2011
Arfrevermannequin
Mannequin
More actions
Python >=3.3 contains os.futimens() and os.utimensat() functions.
I have filed issue bpo-11941, which suggests to add support for nanosecond resolution in result of os.stat().
Activity
shaurz commentedon Oct 19, 2010
When copying a file with shutil.copy2() between two ext4 filesystems on 64-bit Linux, the mtime of the destination file is different after the copy. It appears as if the resolution is slightly different, so the mtime is truncated slightly. For example:
source file mtime: 1287367331.8433506
destination file mtime: 1287367331.84335
loewis commentedon Oct 20, 2010
This is a system limitation. The underlying file system supports nanosecond resolution for the file stamps, and stat(2) also supports reporting them. However, utimes(2) only supports microsecond resolution when setting them.
Linux supports utimensat(2) since 2.6.22 (July 2007), however, Python doesn't use it. It would be possible to come up with a patch to transparently use it where available. Are you interested in writing such a patch?
As a consequential issue: For Python, a long time ago, it was decided that time stamps in system interfaces are floating point numbers. As a consequence, nanoseconds cannot be accurately represented for today's dates (IIUC). I doubt there is anything we could do about this; this is likely "won't fix".
peterjc commentedon Jan 28, 2011
I'm also seeing this on 32bit Windows XP using Python 3.1.2, and Python 3.2rc1 on a local NTFS filesystem.
e.g. from os.stat(filename).st_mtime after using shutil.copy2(...)
1293634856.1402586 source
1293634856.1402581 copied
I've been using shutil.copy2 then expecting st_mtime will be equal (or at least that the copy file will be newer than the original). As you can see in this case, the copy is sometimes a fraction older.
The same issue occurs using shutil.copy then shutils.copystat (probably not a surprise).
Arfrever commentedon Apr 27, 2011
Python >=3.3 contains os.futimens() and os.utimensat() functions.
I have filed issue bpo-11941, which suggests to add support for nanosecond resolution in result of os.stat().
vstinner commentedon Mar 13, 2012
This issue is a duplicate of bpo-14127.
python-dev commentedon May 6, 2012
New changeset 709850f1ec67 by Larry Hastings in branch 'default':
Update Misc/NEWS for issues bpo-14127 and bpo-14705. (And, technically, bpo-10148.)
http://hg.python.org/cpython/rev/709850f1ec67
python-dev commentedon May 6, 2012
New changeset 05274ab06182 by Larry Hastings in branch 'default':
Update Misc/NEWS for issues bpo-14127 and bpo-14705. (And, technically, bpo-10148.)
http://hg.python.org/cpython/rev/05274ab06182