Trying other strategy for #19715: use utime(..., None)

This commit is contained in:
Antoine Pitrou 2013-11-23 01:54:27 +01:00
parent f8d0ff9f42
commit c3055be5f3
2 changed files with 3 additions and 8 deletions

View File

@ -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):
# 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

View File

@ -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())