homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author larry
Recipients larry
Date 2011年09月05日.21:08:00
SpamBayes Score 6.2434224e-11
Marked as misclassified No
Message-id <1315256882.76.0.179568612134.issue12904@psf.upfronthosting.co.za>
In-reply-to
Content
Since Linux 2.5 stat() has supported reading nanosecond resolution (1b/sec) for atime and mtime. However, the utime() family of functions could only write atime and mtime with microsecond resolution (1m/sec) until relatively recently.
On POSIX platforms Python reads atime and mtime at nanosecond resolution but only writes them at microsecond resolution. This impedance mismatch can cause undesirable behavior. Consider the following code:
 import os
 import shutil
 import sys
 def mtime(path):
 return os.stat(path).st_mtime
 src = sys.argv[0]
 dest = src + ".new"
 shutil.copy2(src, dest)
 assert mtime(src) == mtime(dest)
When run under Python on any modern Linux system, the assert fails. (I think any Python since 2.5 will do; I tested with 2.7.1 and a fresh 3.3 trunk.)
The accompanying patch modifies Modules/posixmodule.c so all functions that write atime and mtime use nanosecond resolution when possible. With this patch applied, all the regression tests pass (except the ones for extension modules I didn't compile), and the above code runs to completion.
Happy to hoist the patch up on Rietveld if there's interest.
p.s. I have the commit bit set, so I'd like to be the one to check this in if we get that far.
History
Date User Action Args
2011年09月05日 21:08:02larrysetrecipients: + larry
2011年09月05日 21:08:02larrysetmessageid: <1315256882.76.0.179568612134.issue12904@psf.upfronthosting.co.za>
2011年09月05日 21:08:02larrylinkissue12904 messages
2011年09月05日 21:08:01larrycreate

AltStyle によって変換されたページ (->オリジナル) /