summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2005-01-23 09:19:22 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2005-01-23 09:19:22 (GMT)
commit4d394dfebbcf00e7eec74ee5f4c1b149b3744a91 (patch)
treed64b9e915baa44448f28c7da48e38884367a48a9
parent1083c248dfc55dde9901919e69bcb7fb29fbb7bf (diff)
downloadcpython-4d394dfebbcf00e7eec74ee5f4c1b149b3744a91.zip
cpython-4d394dfebbcf00e7eec74ee5f4c1b149b3744a91.tar.gz
cpython-4d394dfebbcf00e7eec74ee5f4c1b149b3744a91.tar.bz2
Truncate st_?time before comparing it with ST_?TIME in the tests.
-rw-r--r--Doc/lib/libos.tex3
-rw-r--r--Lib/test/test_os.py6
-rw-r--r--Misc/NEWS1
3 files changed, 9 insertions, 1 deletions
diff --git a/Doc/lib/libos.tex b/Doc/lib/libos.tex
index 6065725..669cc8f 100644
--- a/Doc/lib/libos.tex
+++ b/Doc/lib/libos.tex
@@ -1012,6 +1012,9 @@ objects. If newval is True, future calls to stat() return floats, if
it is False, future calls return ints. If newval is omitted, return
the current setting.
+For compatibility with older Python versions, accessing
+\class{stat_result} as a tuple always returns integers.
+
\versionchanged[Python now returns float values by default. Applications
which do not work correctly with floating point time stamps can use
this function to restore the old behaviour]{2.5}
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 25fad18..472d13f 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -111,7 +111,11 @@ class StatAttributeTests(unittest.TestCase):
for name in dir(stat):
if name[:3] == 'ST_':
attr = name.lower()
- self.assertEquals(getattr(result, attr),
+ if name.endswith("TIME"):
+ def trunc(x): return int(x)
+ else:
+ def trunc(x): return x
+ self.assertEquals(trunc(getattr(result, attr)),
result[getattr(stat, name)])
self.assert_(attr in members)
diff --git a/Misc/NEWS b/Misc/NEWS
index ec8570b..cad22cd 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -151,6 +151,7 @@ C API
Tests
-----
+- In test_os, st_?time is now truncated before comparing it with ST_?TIME.
Mac
---