[pypy-svn] r64567 - in pypy/trunk/pypy/module/posix: . test
afa at codespeak.net
afa at codespeak.net
Wed Apr 22 11:31:57 CEST 2009
Author: afa
Date: Wed Apr 22 11:31:55 2009
New Revision: 64567
Modified:
pypy/trunk/pypy/module/posix/app_posix.py
pypy/trunk/pypy/module/posix/test/test_posix2.py
Log:
stat_result.st_mtime was not filled when constructed from a tuple; test and fix.
Found by the twisted buildbot.
Modified: pypy/trunk/pypy/module/posix/app_posix.py
==============================================================================
--- pypy/trunk/pypy/module/posix/app_posix.py (original)
+++ pypy/trunk/pypy/module/posix/app_posix.py Wed Apr 22 11:31:55 2009
@@ -49,6 +49,19 @@
if "st_flags" in posix._statfields:
st_flags = structseqfield(23, "user defined flags for file")
+ def __init__(self, *args, **kw):
+ super(stat_result, self).__init__(*args, **kw)
+
+ # If we have been initialized from a tuple,
+ # st_?time might be set to None. Initialize it
+ # from the int slots.
+ if self.st_atime is None:
+ self.__dict__['st_atime'] = self[7]
+ if self.st_mtime is None:
+ self.__dict__['st_mtime'] = self[8]
+ if self.st_ctime is None:
+ self.__dict__['st_ctime'] = self[9]
+
def fdopen(fd, mode='r', buffering=-1):
"""fdopen(fd [, mode='r' [, buffering]]) -> file_object
Modified: pypy/trunk/pypy/module/posix/test/test_posix2.py
==============================================================================
--- pypy/trunk/pypy/module/posix/test/test_posix2.py (original)
+++ pypy/trunk/pypy/module/posix/test/test_posix2.py Wed Apr 22 11:31:55 2009
@@ -123,6 +123,12 @@
finally:
posix.stat_float_times(current)
+ def test_stat_result(self):
+ st = self.posix.stat_result((0, 0, 0, 0, 0, 0, 0, 41, 42.1, 43))
+ assert st.st_atime == 41
+ assert st.st_mtime == 42.1
+ assert st.st_ctime == 43
+
def test_pickle(self):
import pickle, os
st = self.posix.stat(os.curdir)
More information about the Pypy-commit
mailing list