This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ocean-city
Recipients
Date 2007-03-07.07:34:44
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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))
History
Date User Action Args
2007-08-23 14:51:35adminlinkissue1646728 messages
2007-08-23 14:51:35admincreate