Interesting! Indeed, please create an issue and post a link here.
From a quick look at the code, I can't see any obvious bugs here, the info
seems to be coming directly from FindNextFileW. This will likely require
some more digging.
On Sun, Oct 18, 2020 at 7:37 AM Gregory P. Smith
Could you please file this as an issue on bugs.python.org?
Thanks! -Greg
On Sat, Oct 17, 2020 at 7:25 PM Rob Cliffe via Python-Dev < python-dev@python.org> wrote:
TLDR: In os.scandir directory entries, atime is always a copy of mtime rather than the actual access time.
Demo program: Windows 10, Python 3.8.3:
# osscandirtest.py import time, os with open('Test', 'w') as f: f.write('Anything\n') # Write to a file time.sleep(10) with open('Test', 'r') as f: f.readline() # Read the file print(os.stat('Test')) for DirEntry in os.scandir('.'): if DirEntry.name == 'Test': stat = DirEntry.stat() print(f'scandir DirEntry {stat.st_ctime=} {stat.st_mtime=} {stat.st_atime=}')
Sample output:
os.stat_result(st_mode=33206, st_ino=8162774324687317, st_dev=2230120362, st_nlink=1, st_uid=0, st_gid=0, st_size=10, st_atime=1600631381, st_mtime=1600631371, st_ctime=1600631262) scandir DirEntry stat.st_ctime=1600631262.951019 stat.st_mtime=1600631371.7062848 stat.st_atime=1600631371.7062848
For os.stat, atime is 10 seconds more than mtime, as would be expected. But for os.scandir, atime is a copy of mtime. ISTM that this is a bug, and in fact recently it stopped me from using os.scandir in a program where I needed the access timestamp. No big deal, but ... If it is a feature for some reason, presumably it should be documented.
Best wishes Rob Cliffe _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/RIKQAXZV... Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/INJBNXRK... Code of Conduct: http://python.org/psf/codeofconduct/