[issue14127] add st_*time_ns fileds to os.stat(), add ns keyword to os.*utime*(), os.*utimens*() expects a number of nanoseconds

STINNER Victor report at bugs.python.org
Tue Mar 13 14:26:54 CET 2012


STINNER Victor <victor.stinner at gmail.com> added the comment:

The following changes has to be done to fix this issue:

 - add st_atime_ns, st_mtime_ns and st_ctime_ns fileds to os.stat() result: number of nanoseconds since Epoch (1970.1.1), an integer
 - change os.*utime*() functions (see below)
 - shutil.copystat() should use os.utime(ns=...) and os.ltime(ns=...)

List of the os.*utime*() functions:

 - os.futimes(): use futimens() or futimes()
 - os.futimens(): use futimens(); UTIME_NOW and UTIME_OMIT flags
 - os.futimesat(): use utimensat() or futimesat()
 - os.lutimes(): use futimesat(AT_SYMLINK_NOFOLLOW) or lutimes()
 - os.utime(): use SetFileTime() (Windows), utimensat(), utimes() or utime()
 - os.utimensat(): use utimensat(); UTIME_NOW and UTIME_OMIT flags

Changes on the os.*utime*() functions:

 - add ns keyword to:

   * os.futimes()
   * os.futimesat()
   * os.lutimes()
   * os.utime()

 - except a number of nanoseconds instead of a number of seconds:

   * os.futimens()
   * os.utimensat()

The ns keyword is an exclusive parameter with existing times parameter. Examples:

   * seconds: os.utime(name, (1, 2))
   * seconds: os.utime(name, times=(1, 2))
   * nanoseconds: os.utime(name, ns=(1, 2))
   * INVALID! os.utime(name, (1, 2), ns=(1, 2))
   * INVALID! os.utime(name, times=(1, 2), ns=(1, 2))

I don't want to remove os.futimens() and os.utimensat() because they add a feature: UTIME_NOW and UTIME_OMIT flags.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14127>
_______________________________________


More information about the Python-bugs-list mailing list