Eryk Sun <[email protected]> added the comment:
For example, the named-pipe filesystem (NPFS), doesn't return timestamps for
pipes in the directory listing, so the timestamps are all 0 (i.e. 1601-01-01):
>>> write_time = win32file.FindFilesW('//./pipe/*')[0][3]
>>> format(write_time, '%Y-%m-%d %H:%M')
'1601-01-01 00:00'
>>> next(os.scandir('//./pipe')).stat().st_mtime
-11644473600.0
I agree that a zero-valued NT timestamp should be converted to a zero-valued
Unix timestamp. No one has a file that was created, modified, changed, or
accessed in 1601.
As mentioned above, the 1601 date doesn't roundtrip in Windows as a Unix
timestamp since dates before the Unix epoch aren't supported:
>>> write_time.timestamp()
-11644473600.0
>>> datetime.fromtimestamp(write_time.timestamp())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument
----------
components: +Library (Lib) -Interpreter Core
nosy: +paul.moore
title: Invalid timestamps reported by os.stat() when Windows FILETIME
structures are mistakenly reset. -> zero-valued timestamps are mishandled by
os.stat() in Windows
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 2.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue23946>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com