STINNER Victor <[email protected]> added the comment:
> File ".../Lib/test/test_time.py", line 351, in test_mktime
> self.assertEqual(time.mktime(tt), t)
> OverflowError: mktime argument out of range
I don't know which values are "out of range". But I guess that the test fails
because of t=-1, which would mean that tm_wday field is not modified by
mktime().
I don't know if mktime() does really not support t=-1, or if we should use
another sentinel. The original patch to fix this issue (support t=-1, issue
#1726687) used tm_wday=42 instead of tm_wday=-1:
+ /* invalid value that will not be changed if there is an error. */
+ buf.tm_wday = 42;
tt = mktime(&buf);
- if (tt == (time_t)(-1)) {
+ if ((tt == (time_t)(-1)) && (buf.tm_wday == 42)) {
PyErr_SetString(PyExc_OverflowError,
"mktime argument out of range");
return NULL;
The current code uses:
buf.tm_wday = -1; /* sentinel; original value ignored */
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) {
PyErr_SetString(PyExc_OverflowError,
"mktime argument out of range");
return NULL;
}
> File ".../Lib/test/test_time.py", line 337, in test_negative
> self.assertIn(text, ('-1', '-001'))
> AssertionError: '000/' not found in ('-1', '-001')
AIX doesn't support negative tm_year value. It should be added to the
timemodule blacklist (#ifdef):
#if defined(_MSC_VER) || defined(sun)
if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) {
PyErr_Format(PyExc_ValueError,
"strftime() requires year in [1; 9999]",
buf.tm_year + 1900);
return NULL;
}
#endif
I don't know if there is a reliable C define to check if the current OS is AIX
(something like #ifdef sun). Python configure script checks if "uname -s"
output starts with "AIX". We should maybe add a Python define in pyconfig.h
using the configure script.
----------
_______________________________________
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