[New-bugs-announce] [issue19727] os.utime(..., None) has poor resolution on Windows

Antoine Pitrou report at bugs.python.org
Sat Nov 23 02:15:52 CET 2013


New submission from Antoine Pitrou:

os.utime() uses the following code when times is None under Windows:

        SYSTEMTIME now;
        GetSystemTime(&now);
        if (!SystemTimeToFileTime(&now, &mtime) ||
            !SystemTimeToFileTime(&now, &atime)) {
            PyErr_SetFromWindowsErr(0);
            goto exit;
        }

The problem is GetSystemTime has poor resolution (milliseconds). Instead, it could call GetSystemTimeAsFileTime which writes directly into a FILETIME structure, and potentially (?) has better resolution.

(according to a comment on MSDN, "Resolution on Windows 7 seems to be sub-millisecond": http://msdn.microsoft.com/en-us/library/windows/desktop/ms724397%28v=vs.85%29.aspx )

----------
components: Library (Lib), Windows
messages: 203943
nosy: brian.curtin, larry, loewis, pitrou, steve.dower, tim.golden, tim.peters
priority: normal
severity: normal
status: open
title: os.utime(..., None) has poor resolution on Windows
type: behavior
versions: Python 3.4

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


More information about the New-bugs-announce mailing list