This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients David.Edelsohn, Dormouse759, hroncok, vstinner
Date 2020-01-29.02:03:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580263383.02.0.560484845748.issue39460@roundup.psfhosted.org>
In-reply-to
Content
"""
$ ./python utime_stat_localtime2.py 
os.utime (sec): 4386268800
os.stat (sec int): 2147483647
os.stat (sec float): 2147483647.0
os.stat (ns): 2147483647000000000
"""

It doesn't make sense !? In msg360916, you had:

os.stat (sec): 4386268800 <= os.stat().st_mtime
os.stat (ns): 2147483647000000000 <= os.stat().st_mtime._ns

How is it possible that sometimes st_mtime is right, and sometimes st_mtime is so plain wrong?

--

Test setting mtime in Python, reading mtime using /usr/bin/stat, then reading file stat in Python:

$ touch testfn

$ python3 -c 'import os; os.utime("testfn", (4386268800, 4386268800))'

$ stat testfn 
(...)
Modify: 2108-12-30 01:00:00.000000000 +0100
(...)

$ python3 -c 'import os; st=os.stat("testfn"); print(st); print(tuple(st)); print(st.st_mtime_ns)'

os.stat_result(st_mode=33204, st_ino=24648296, st_dev=40, st_nlink=1, st_uid=1000, st_gid=1000, st_size=0, st_atime=4386268800, st_mtime=4386268800, st_ctime=1580263179)
(33204, 24648296, 40, 1, 1000, 1000, 0, 4386268800, 4386268800, 1580263179)
4386268800000000000
History
Date User Action Args
2020-01-29 02:03:03vstinnersetrecipients: + vstinner, David.Edelsohn, hroncok, Dormouse759
2020-01-29 02:03:03vstinnersetmessageid: <1580263383.02.0.560484845748.issue39460@roundup.psfhosted.org>
2020-01-29 02:03:03vstinnerlinkissue39460 messages
2020-01-29 02:03:02vstinnercreate