Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
Bug report
Bug description:
We are switching our product to Python 3.12 from Python 3.11.2 and our tests caught a difference in the wayos.stat works under Windows. It returns negative values ofst_atime,st_mtime, andst_ctime if there are no permissions assigned to the file.
How to reproduce: you can remove all permissions using Windows Explorer, right-click on a file, select "Properties", select "Security" tab, press "Edit" button, and finally remove all entries from the "Group and user names" list. Or remove all inherited permissions in "Properties / Security /Advanced" window,icacls should show an empty list of permissions, for example:
PS C:\...> icacls a.txta.txtSuccessfully processed 1 files; Failed processing 0 files
and then check the output in Python 3.12:
(python-312)PSC:\...>python-c"import os; print(os.stat('a.txt'))"os.stat_result(st_mode=33206,st_ino=0,st_dev=0,st_nlink=0,st_uid=0,st_gid=0,st_size=0,st_atime=-11644473600,st_mtime=-11644473600,st_ctime=-11644473600)
and the same for Python 3.11.2, which is correct:
(python-311)PSC:\...>python-c"import os; print(os.stat('a.txt'))"os.stat_result(st_mode=33206,st_ino=0,st_dev=0,st_nlink=0,st_uid=0,st_gid=0,st_size=0,st_atime=1699527432,st_mtime=1699527008,st_ctime=1699527008)
The returned value sounds likesecs_between_epochs fromhttps://github.com/python/cpython/blob/main/Python/fileutils.c#L1050 Maybe it has something to do with the issue.
CPython versions tested on:
3.12
Operating systems tested on:
Windows