Commit 2cf39179 authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #19715: try the utime(..., None) approach again, now that it should be...

Issue #19715: try the utime(..., None) approach again, now that it should be more precise under Windows
parent 91a7af3e
...@@ -6,7 +6,6 @@ import os ...@@ -6,7 +6,6 @@ import os
import posixpath import posixpath
import re import re
import sys import sys
import time
import weakref import weakref
try: try:
import threading import threading
...@@ -1076,9 +1075,8 @@ class Path(PurePath): ...@@ -1076,9 +1075,8 @@ class Path(PurePath):
# First try to bump modification time # First try to bump modification time
# Implementation note: GNU touch uses the UTIME_NOW option of # Implementation note: GNU touch uses the UTIME_NOW option of
# the utimensat() / futimens() functions. # the utimensat() / futimens() functions.
t = time.time()
try: try:
self._accessor.utime(self, (t, t)) self._accessor.utime(self, None)
except OSError: except OSError:
# Avoid exception chaining # Avoid exception chaining
pass pass
......
...@@ -1391,11 +1391,8 @@ class _BasePathTest(object): ...@@ -1391,11 +1391,8 @@ class _BasePathTest(object):
# The file mtime should be refreshed by calling touch() again # The file mtime should be refreshed by calling touch() again
p.touch() p.touch()
st = p.stat() st = p.stat()
# Issue #19715: there can be an inconsistency under Windows between self.assertGreaterEqual(st.st_mtime_ns, old_mtime_ns)
# the timestamp rounding when creating a file, and the timestamp self.assertGreaterEqual(st.st_mtime, old_mtime)
# 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)
# Now with exist_ok=False # Now with exist_ok=False
p = P / 'newfileB' p = P / 'newfileB'
self.assertFalse(p.exists()) self.assertFalse(p.exists())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment