[Python-checkins] cpython: Issue #19715: try the utime(..., None) approach again, now that it should be
antoine.pitrou
python-checkins at python.org
Sat Nov 23 15:26:06 CET 2013
http://hg.python.org/cpython/rev/b5e9d61f6987
changeset: 87420:b5e9d61f6987
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Nov 23 15:25:59 2013 +0100
summary:
Issue #19715: try the utime(..., None) approach again, now that it should be more precise under Windows
files:
Lib/pathlib.py | 4 +---
Lib/test/test_pathlib.py | 7 ++-----
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -6,7 +6,6 @@
import posixpath
import re
import sys
-import time
import weakref
try:
import threading
@@ -1076,9 +1075,8 @@
# 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
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -1391,11 +1391,8 @@
# 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())
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list