Message128556
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. |
|
Date |
User |
Action |
Args |
2011-02-14 16:48:01 | sable | set | recipients:
+ sable, belopolsky, vstinner |
2011-02-14 16:48:01 | sable | set | messageid: <1297702081.83.0.612100426261.issue11188@psf.upfronthosting.co.za> |
2011-02-14 16:48:00 | sable | link | issue11188 messages |
2011-02-14 16:48:00 | sable | create | |
|