From: Antoine Pitrou Date: Sat, 23 Nov 2013 14:25:59 +0000 (+0100) Subject: Issue #19715: try the utime(..., None) approach again, now that it should be more... X-Git-Tag: v3.4.0b1~69^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2cf3917954dab65c025ea39f8b6a0298c598f9f7;p=thirdparty%2FPython%2Fcpython.git Issue #19715: try the utime(..., None) approach again, now that it should be more precise under Windows --- diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 06cbae5ce3d1..e73eca7ec9f0 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -6,7 +6,6 @@ import os import posixpath import re import sys -import time import weakref try: import threading @@ -1076,9 +1075,8 @@ class Path(PurePath): # First try to bump modification time # Implementation note: GNU touch uses the UTIME_NOW option of # the utimensat() / futimens() functions. - t = time.time() try: - self._accessor.utime(self, (t, t)) + self._accessor.utime(self, None) except OSError: # Avoid exception chaining pass diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 83c56d0d9bcb..4108d5e2fd9f 100755 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1391,11 +1391,8 @@ class _BasePathTest(object): # The file mtime should be refreshed by calling touch() again p.touch() st = p.stat() - # Issue #19715: there can be an inconsistency under Windows between - # the timestamp rounding when creating a file, and the timestamp - # rounding done when calling utime(). `delta` makes up for this. - delta = 1e-6 if os.name == 'nt' else 0 - self.assertGreaterEqual(st.st_mtime, old_mtime - delta) + self.assertGreaterEqual(st.st_mtime_ns, old_mtime_ns) + self.assertGreaterEqual(st.st_mtime, old_mtime) # Now with exist_ok=False p = P / 'newfileB' self.assertFalse(p.exists())