homepage

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 vstinner
Recipients belopolsky, sable, vstinner
Date 2011年02月14日.12:28:57
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1297686538.17.0.609880307441.issue11188@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2011年02月14日 12:28:58vstinnersetrecipients: + vstinner, belopolsky, sable
2011年02月14日 12:28:58vstinnersetmessageid: <1297686538.17.0.609880307441.issue11188@psf.upfronthosting.co.za>
2011年02月14日 12:28:57vstinnerlinkissue11188 messages
2011年02月14日 12:28:57vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /