You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
os.utimensat() and os.futimes() should accept (sec, nsec), drop os.futimens() #58172
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2012-03-13.13:05:15.803>created_at=<Date2012-02-08.01:19:53.483>labels= ['library']
title='os.utimensat() and os.futimes() should accept (sec, nsec), drop os.futimens()'updated_at=<Date2012-03-13.13:05:15.802>user='https://github.com/vstinner'
Python 3.3 has 4 new functions to set the access and modification time of a file (only os.utime() was already present in Python 3.2). New functions taking timestamp with a nanonsecond resolution use a tuple of int because the float type doesn't support nanosecond resolution. Thanks to the PEP-410, we can simplify the API to use a simple number (int, float or Decimal) instead of a tuple of 2 integers.
Current API:
futimes(fd[, (atime, mtime)]): 1 argument for timestamps
lutimes(path[, (atime, mtime)]): 1 argument for timestamps
utime(path[, (atime, mtime)]): 1 argument for timestamps
futimens(fd[, (atime_sec, atime_nsec), (mtime_sec, mtime_nsec)]): 2 arguments for timestamps
I suggest to support the following functions:
futimes(fd, (atime, mtime), flags=0)
utimes(path, (atime, mtime), flags=0)
utimesat(dirfd, path, (atime, mtime), flags=0)
And deprecate other functions already present in 3.2.
flags argument of utimes*() would specify e.g. if symlinks should be dereferenced, so lutime*() wouldn't be needed.
signal.sigtimedwait() API should also be changed from:
sigtimedwait(sigset, (timeout_sec, timeout_nsec))
to:
sigtimedwait(sigset, timeout)
where timeout can be an int, float or decimal.Decimal. The function was introduced in Python 3.3, so its API can be changed.
Arfrever commented on Feb 9, 2012
Arfrevermannequin
Mannequin
More actions
Updated version of my suggestion:
os.futime(fd, (atime, mtime))
os.utime(path, (atime, mtime), flags=0)
os.utimeat(dirfd, path, (atime, mtime), flags=0)
atime and mtime could be int, float, decimal.Decimal or None.
All other os.*utime*() functions were introduced in 3.3, so they would be removed.
flags argument of os.utime() and os.utimeat() could be 0 or os.SYMLINK_NOFOLLOW.
I chose pytime.h instead of timefuncs.h because I plan to use _PyTime_ObjectToTimespec() in the posix module. I don't want to have a copy of this function in each module: timefuncs.h requires to compile the module with _time.c.
Um, doesn't the rejection of PEP-410 mean this should be discontinued?
There is an issue in shutil.copystat() on copying the timestamp: in this specific use case, we need nanosecond resolution.
Guido proposes (in a private mail thread) to add st_atime_ns, st_mtime_ns, st_ctime_ns fields to os.stat() and make os.*utime*() functions accept a (sec, nsec) tuple. It would still be possible to pass a number or seconds as an int or float.
changed the title [-]os.utimensat() and os.futimes() should accept Decimal, drop os.futimens()[/-][+]os.utimensat() and os.futimes() should accept (sec, nsec), drop os.futimens()[/+]on Mar 3, 2012
After Guido rejected 410 and said "let's just do nanoseconds, take it to the bug tracker" I created issue bpo-14127. Your having changed this issue to be the same thing means that at least one of 'em is redundant. Could you engage on that issue, or close it, or something?
I just asked Guido in person, and he says he never intended to suggest accepting a (sec, nsec) tuple. os.*utime* may accept atime and mtime as either float seconds-since-the-epoch, or int nanoseconds-since-the-epoch when passed in using the ns= named parameter.
Activity
vstinner commentedon Feb 8, 2012
Python 3.3 has 4 new functions to set the access and modification time of a file (only os.utime() was already present in Python 3.2). New functions taking timestamp with a nanonsecond resolution use a tuple of int because the float type doesn't support nanosecond resolution. Thanks to the PEP-410, we can simplify the API to use a simple number (int, float or Decimal) instead of a tuple of 2 integers.
Current API:
futimes(fd[, (atime, mtime)]): 1 argument for timestamps
lutimes(path[, (atime, mtime)]): 1 argument for timestamps
utime(path[, (atime, mtime)]): 1 argument for timestamps
futimens(fd[, (atime_sec, atime_nsec), (mtime_sec, mtime_nsec)]): 2 arguments for timestamps
utimensat(dirfd, path[, atime=(atime_sec, atime_nsec), mtime=(mtime_sec, mtime_nsec), flags=0]): 2 arguments for timestamps
I propose to:
python-dev commentedon Feb 8, 2012
New changeset d297f9b10c64 by Victor Stinner in branch 'default':
Issue bpo-13964: Write tests for new os.*utime*() functions
http://hg.python.org/cpython/rev/d297f9b10c64
vstinner commentedon Feb 8, 2012
Oh, I forgot:
This API looks fine.
python-dev commentedon Feb 8, 2012
New changeset c6e9c4d18b36 by Victor Stinner in branch 'default':
Issue bpo-13964: Test also os.futimesat()
http://hg.python.org/cpython/rev/c6e9c4d18b36
Arfrever commentedon Feb 8, 2012
I suggest to support the following functions:
futimes(fd, (atime, mtime), flags=0)
utimes(path, (atime, mtime), flags=0)
utimesat(dirfd, path, (atime, mtime), flags=0)
And deprecate other functions already present in 3.2.
flags argument of utimes*() would specify e.g. if symlinks should be dereferenced, so lutime*() wouldn't be needed.
python-dev commentedon Feb 8, 2012
New changeset 478fb4869c99 by Victor Stinner in branch 'default':
Issue bpo-13964: Split os.*utime*() subsecond tests into multiple tests to help
http://hg.python.org/cpython/rev/478fb4869c99
python-dev commentedon Feb 8, 2012
New changeset 58bd6a58365d by Victor Stinner in branch 'default':
Issue bpo-13964: Skip os.*utime*() tests if os.stat() doesn't support timestamp
http://hg.python.org/cpython/rev/58bd6a58365d
vstinner commentedon Feb 8, 2012
Oops, I also commited my change on extract_time() by mistake. But it is not completly a mistake: it was the goal of my patch serie :-)
This commit changes two things on extract_time().
vstinner commentedon Feb 9, 2012
signal.sigtimedwait() API should also be changed from:
sigtimedwait(sigset, (timeout_sec, timeout_nsec))
to:
sigtimedwait(sigset, timeout)
where timeout can be an int, float or decimal.Decimal. The function was introduced in Python 3.3, so its API can be changed.
Arfrever commentedon Feb 9, 2012
Updated version of my suggestion:
os.futime(fd, (atime, mtime))
os.utime(path, (atime, mtime), flags=0)
os.utimeat(dirfd, path, (atime, mtime), flags=0)
atime and mtime could be int, float, decimal.Decimal or None.
All other os.*utime*() functions were introduced in 3.3, so they would be removed.
flags argument of os.utime() and os.utimeat() could be 0 or os.SYMLINK_NOFOLLOW.
vstinner commentedon Feb 21, 2012
Here is a first step: add _PyTime_ObjectToTimespec() to pytime.h and use it for signal.sigtimedwait().
signal.sigtimedwait(sigwait, (timeout_sec, timeout_nsec)) becomes signal.sigtimedwait(sigwait, timeout).
I chose pytime.h instead of timefuncs.h because I plan to use _PyTime_ObjectToTimespec() in the posix module. I don't want to have a copy of this function in each module: timefuncs.h requires to compile the module with _time.c.
python-dev commentedon Mar 2, 2012
New changeset 67d9595a833c by Victor Stinner in branch 'default':
Issue bpo-13964: signal.sigtimedwait() timeout is now a float instead of a tuple
http://hg.python.org/cpython/rev/67d9595a833c
vstinner commentedon Mar 3, 2012
I created the issue bpo-14180 to prepare a refactoring before changing os.*utime*() functions.
larryhastings commentedon Mar 3, 2012
Um, doesn't the rejection of PEP-410 mean this should be discontinued?
vstinner commentedon Mar 3, 2012
There is an issue in shutil.copystat() on copying the timestamp: in this specific use case, we need nanosecond resolution.
Guido proposes (in a private mail thread) to add st_atime_ns, st_mtime_ns, st_ctime_ns fields to os.stat() and make os.*utime*() functions accept a (sec, nsec) tuple. It would still be possible to pass a number or seconds as an int or float.
I plan to implement this request.
[-]os.utimensat() and os.futimes() should accept Decimal, drop os.futimens()[/-][+]os.utimensat() and os.futimes() should accept (sec, nsec), drop os.futimens()[/+]vstinner commentedon Mar 4, 2012
utime.patch: ugly draft to add support of (sec, nsec) tuple to os.*utime*() functions.
larryhastings commentedon Mar 4, 2012
After Guido rejected 410 and said "let's just do nanoseconds, take it to the bug tracker" I created issue bpo-14127. Your having changed this issue to be the same thing means that at least one of 'em is redundant. Could you engage on that issue, or close it, or something?
larryhastings commentedon Mar 8, 2012
I just asked Guido in person, and he says he never intended to suggest accepting a (sec, nsec) tuple. os.*utime* may accept atime and mtime as either float seconds-since-the-epoch, or int nanoseconds-since-the-epoch when passed in using the ns= named parameter.
vstinner commentedon Mar 13, 2012
This issue is a duplicate of bpo-14127.