[IronPython] problem with IronPython 1.0 and os.utime ?

Dino Viehland dinov at exchange.microsoft.com
Fri Sep 8 22:49:31 CEST 2006


There's two issues here, I've opened bug #3050 to track this (http://www.codeplex.com/WorkItem/List.aspx?ProjectName=IronPython).

The 1st issue is that nt.utime is steting the LastAccessTime twice - obviously we want to set LastAccess once, and LastWrite once.

The 2nd issue is that we're doing the wrong calculating for setting the time - this is the reason LastAccess is getting thrown off so much.

I've tentatively opened this as a 1.01 bug fix bug if you'd like to workaround it until then you can replace the existing block that handles this in SetFileTimes in IronPython\Modules\nt.cs with:

                } else if (times.Count == 2) {
                    DateTime atime = DateTime.MinValue.Add(TimeSpan.FromSeconds(Converter.ConvertToDouble(times[0])));
                    DateTime mtime = DateTime.MinValue.Add(TimeSpan.FromSeconds(Converter.ConvertToDouble(times[1])));

                    fi.LastAccessTime = atime;
                    fi.LastWriteTime = mtime;

This removes a hard coded date and switches to DateTime.MinValue and then also sets the 2 values instead of just one.   Thanks for the bug report!


-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Bern.McCarty at bentley.com
Sent: Thursday, September 07, 2006 12:39 PM
To: users at lists.ironpython.com
Subject: [IronPython] problem with IronPython 1.0 and os.utime ?


I am using IronPython 1.0 under Windows XP and using the python libraries from ActivePython 2.4 Build 243. When I run this program under
IronPython:

import os
import stat

def printFileTimes(st):
    print 'Last Access:       ', st[stat.ST_ATIME]
    print 'Last Modification: ', st[stat.ST_MTIME]
    print 'Creation Time:     ', st[stat.ST_CTIME]
    print

def main():
    filename = 'testfile.txt'
    oOutFile = open(filename , 'w')
    oOutFile.writelines(['Line 1\n', 'Line 2\n', 'Line 3\n'])
    oOutFile.close()

    st1 = os.stat(filename)
    printFileTimes(st1)
    print 'Now set the last-access and last-mod times to what they supposedly already are.'
    os.utime(filename, (st1[stat.ST_ATIME], st1[stat.ST_MTIME]))
    st2 = os.stat(filename)
    printFileTimes(st2)
    print 'So what is up with that last-access time now? Why did it change?'

if __name__ == '__main__':
    main()



I get this output:



Last Access:        63293240071
Last Modification:  63293240071
Creation Time:      63293239100

Now set the last-access and last-mod times to what they supposedly already are.
Last Access:        125428808071
Last Modification:  63293240071
Creation Time:      63293239100

So what is up with that last-access time now? Why did it change?


Whereas under Cpython it works as expected.
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list