os.path.getmtime on winXP

Bengt Richter bokr at oz.net
Tue Nov 8 17:23:54 EST 2005


On Tue, 08 Nov 2005 13:33:12 +0100, =?ISO-8859-1?Q?Jorg_R=F8dsj=F8?= <jorg at neoplex.org> wrote:

>Bengt Richter wrote:
>> By 'getmtime' you mean os.path.getmtime(fer_shure_or_absolute_path_to_file) right?
>> Doesn't that get you an integer number of seconds? What GUI or win32file is showing you
>> that integer so you see a 3600 sec difference? Or how are you seeing it?
>> 
>> Could you paste an example of this difference from an example on your screen?
>> I don't think I am understanding ;-) ... urk, it's late ;-/
>
>(Btw: thanks for the interest.)
>
>Step by step example:
>[I do of cource not modify the foo.py-file at any time during the testing.]
>
>With the system-date set to the 8th of november(no dst) I run the following
>os.path.getmtime('spam.py'), and get 1045578240 as the result.
>
>With the system-date set to the 8th of october(dst) I run the following
>os.path.getmtime('spam.py'), and get 1045581840 as the result.
>
>This is what boggles my mind. These numbers should be the same -- right? 
>Not offsett by 3600.
>
>On both dates, calling Windows win32file.GetFileTime (from the Python 
>Win32 Extensions) gives me the time 02/18/03 14:24:00 -- i.e. the same 
>both before and after setting the time.
>
>I have not looked at the source to either win32file.GetFileTime or 
>os.path.getmtime, but I should think that they should both call the same 
>underlying Windows-function.
>
>I hope this makes it more clear. Any idea why this happens?
>
Ok, now it's clear, thanks ;-)

Well, it seems like a bug, on the face of it.
os.path (at least when it is alias for ntpath.py) just calls os.stat:
"""
def getmtime(filename):
    """Return the last modification time of a file, reported by os.stat()"""
    return os.stat(filename).st_mtime
"""
So maybe the next step is to check os.stat to verify it does the same, and then
get to the bottom of how os.stat is is really implemented.

Regards,
Bengt Richter



More information about the Python-list mailing list