[Python-Dev] Re: os.scandir bug in Windows?

2020年10月18日 10:10:57 -0700

On 10/18/2020 12:25 PM, Rob Cliffe via Python-Dev wrote:
How do I do that, please? I can't see an obvious create option on that web page. Do I need to log in?
Yes, you need to log in before you can open an issue. You might need to create an account first if you don't have one: it's called "Register" on bpo. After you've logged in, there's a Create New button.
Eric
Thanks
Rob Cliffe
On 18/10/2020 05:31, Gregory P. Smith wrote:
Could you please file this as an issue on bugs.python.org <http://bugs.python.org>?
Thanks!
-Greg
On Sat, Oct 17, 2020 at 7:25 PM Rob Cliffe via Python-Dev <[email protected] <mailto:[email protected]>> 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 -- [email protected]
 <mailto:[email protected]>
 To unsubscribe send an email to [email protected]
 <mailto:[email protected]>
 https://mail.python.org/mailman3/lists/python-dev.python.org/
 Message archived at
 
https://mail.python.org/archives/list/[email protected]/message/RIKQAXZVUAQBLECFMNN2PUOH322B2BYD/
 Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/377JYZMK3MITKPCCGWQ43R5FPZPO2ADA/
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/YEELT5B3UWQOV2WPMJ4OTFWCMIQMO63X/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to