[issue19715] test_touch_common failure under Windows

Steve Dower report at bugs.python.org
Sat Nov 23 06:09:49 CET 2013


Steve Dower added the comment:

The "000" or "500" still smells of floating point rounding to me. Windows appears to round-trip the values provided perfectly:

import ctypes
def do_test(t):
    h = ctypes.windll.kernel32.CreateFileW("test.txt", 0xC0000000, 7, None, 2, 0, 0)
    assert h != -1
    try:
        mt1 = ctypes.c_uint64(t)
        assert ctypes.windll.kernel32.SetFileTime(h, None, None, ctypes.byref(mt1)) != 0
        mt2 = ctypes.c_uint64()
        assert ctypes.windll.kernel32.GetFileTime(h, None, None, ctypes.byref(mt2)) != 0
        assert mt1.value == mt2.value
        print(mt2.value)
    finally:
        assert ctypes.windll.kernel32.CloseHandle(h) != 0

>>> do_test(123)
123
>>> do_test(999999999999999999)
999999999999999999

Now, I'm not going to make any claims about GetSystemTime's accuracy, and there could well be floating point conversions within there that cause the rounding issue, but I'm more inclined to think that one of Python's conversions is at fault.

Of course, an easy way around this would be to sleep for >100ns before touching the file again.

----------

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


More information about the Python-bugs-list mailing list