Sébastien Sablé <[email protected]> added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue11188>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com