Message31123
Hello, I'm user of Windows (Now building Python2.5 with VC6)
I heard localtime() can only handle positive time_t on windows,
so datetime.fromtimestamp() also fails for negative value.
>>> datetime.datetime.fromtimestamp(-1.05)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: timestamp out of range for platform localtime()/gmtime() function
>>> datetime.datetime.fromtimestamp(-1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: timestamp out of range for platform localtime()/gmtime() function
I'll attach workaround for unittest. Probably there is better way
skip this test on non-negative platform though :-)
Index: Lib/test/test_datetime.py
===================================================================
--- Lib/test/test_datetime.py (revision 54194)
+++ Lib/test/test_datetime.py (working copy)
@@ -1428,9 +1428,17 @@
def test_negative_float_fromtimestamp(self):
# The result is tz-dependent; at least test that this doesn't
# fail (like it did before bug 1646728 was fixed).
+ try:
+ self.theclass.fromtimestamp(-1)
+ except ValueError: # cannot handle negative value
+ return
self.theclass.fromtimestamp(-1.05)
def test_negative_float_utcfromtimestamp(self):
+ try:
+ self.theclass.utcfromtimestamp(-1)
+ except ValueError: # cannot handle negative value
+ return
d = self.theclass.utcfromtimestamp(-1.05)
self.assertEquals(d, self.theclass(1969, 12, 31, 23, 59, 58, 950000))
|
|
Date |
User |
Action |
Args |
2007-08-23 14:51:35 | admin | link | issue1646728 messages |
2007-08-23 14:51:35 | admin | create | |
|