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 sable
Recipients belopolsky, sable, vstinner
Date 2011-02-14.16:48:00
SpamBayes Score 1.348569e-10
Marked as misclassified No
Message-id <1297702081.83.0.612100426261.issue11188@psf.upfronthosting.co.za>
In-reply-to
Content
I tried the following patch (_AIX is defined on AIX platforms):

Index: Modules/timemodule.c
===================================================================
--- Modules/timemodule.c	(révision 88420)
+++ Modules/timemodule.c	(copie de travail)
@@ -474,7 +474,7 @@
     else if (!gettmarg(tup, &buf) || !checktm(&buf))
         return NULL;
 
-#if defined(_MSC_VER) || defined(sun)
+#if defined(_MSC_VER) || defined(sun) || defined(_AIX)
     if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) {
         PyErr_Format(PyExc_ValueError,
                      "strftime() requires year in [1; 9999]",
@@ -694,11 +694,12 @@
     time_t tt;
     if (!gettmarg(tup, &buf))
         return NULL;
-    buf.tm_wday = -1;  /* sentinel; original value ignored */
+    /* invalid value that will not be changed if there is an error. */
+    buf.tm_wday = 42;
     tt = mktime(&buf);
     /* Return value of -1 does not necessarily mean an error, but tm_wday
      * cannot remain set to -1 if mktime succedded. */
-    if (tt == (time_t)(-1) && buf.tm_wday == -1) {
+    if ((tt == (time_t)(-1)) && (buf.tm_wday == 42)) {
         PyErr_SetString(PyExc_OverflowError,
                         "mktime argument out of range");
         return NULL;

This resulted in the following:
======================================================================
ERROR: test_mktime (__main__.TestAsctime4dyear)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_time.py", line 351, in test_mktime
    self.assertEqual(time.mktime(tt), t)
OverflowError: mktime argument out of range

======================================================================
ERROR: test_mktime (__main__.TestStrftime4dyear)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_time.py", line 351, in test_mktime
    self.assertEqual(time.mktime(tt), t)
OverflowError: mktime argument out of range

======================================================================
ERROR: test_mktime (__main__.Test4dyearBool)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_time.py", line 351, in test_mktime
    self.assertEqual(time.mktime(tt), t)
OverflowError: mktime argument out of range

----------------------------------------------------------------------
Ran 42 tests in 1.395s

FAILED (errors=3)

So test_negative is now OK, but tm_wday = 42 did not solve the problem it seems.
History
Date User Action Args
2011-02-14 16:48:01sablesetrecipients: + sable, belopolsky, vstinner
2011-02-14 16:48:01sablesetmessageid: <1297702081.83.0.612100426261.issue11188@psf.upfronthosting.co.za>
2011-02-14 16:48:00sablelinkissue11188 messages
2011-02-14 16:48:00sablecreate