[issue1726687] Bug found in datetime for Epoch time = -1

Alexander Belopolsky report at bugs.python.org
Thu Feb 18 23:28:56 CET 2010

Alexander Belopolsky <alexander.belopolsky at gmail.com> added the comment:

I wonder: with year bounds being checked in gettmarg() and mktime accepting arbitrary values for the rest of the tm structure members (at least it appears to on my Mac), is it possible trigger "mktime argument out of range"?

If it is possible, then a unit test should be added for such case.  Note that the issue2736 patch contains a typo that assures that overflow is never reported, but the unit test presented here does not catch that bug:

+	buf.tm_wday = -1;
 	tt = mktime(&buf);
-	if (tt == (time_t)(-1)) {
+	if (tt == (time_t)(-1) && buf.tm_wday == 1) {
 				"mktime argument out of range");
(Note missing '-' in buf.tm_wday == 1 check. See issue2736.)


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list