[issue11850] mktime - OverflowError: mktime argument out of range - on very specific time
New submission from JoeKuan : >>> a = (1970, 1, 1, 0, 59, 58, 0, 0, 0) >>> time.mktime(a) -2.0 >>> a = (1970, 1, 1, 0, 59, 59, 0, 0, 0) >>> time.mktime(a) Traceback (most recent call last): File "", line 1, in OverflowError: mktime argument out of range >>> a = (1970, 1, 1, 1, 0, 0, 0, 0, 0) >>> time.mktime(a) 0.0 >>> a = (1970, 1, 1, 0, 59, 60, 0, 0, 0) >>> time.mktime(a) 0.0 -- messages: 133806 nosy: JoeKuan priority: normal severity: normal status: open title: mktime - OverflowError: mktime argument out of range - on very specific time versions: Python 2.6 ___ Python tracker <http://bugs.python.org/issue11850> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11850] mktime - OverflowError: mktime argument out of range - on very specific time
JoeKuan added the comment: I don't think it is to do with the underlying C mktime. Because it works fine with 00:59:58 and 01:00:00, 1, Jan 1970. It is to do with some specific value -1 in the internal code of time.mktime Here is the C code. int main(int argc, char *argv[]) { struct tm aTime = { 58, 59, 0, 1, 0, 70, 0, 0, 0, 0 }; time_t mTime = mktime(&aTime); printf("%s\n", ctime(&mTime)); aTime.tm_sec = 59; mTime = mktime(&aTime); printf("%s\n", ctime(&mTime)); aTime.tm_sec = 0; aTime.tm_min = 0; aTime.tm_hour = 1; mTime = mktime(&aTime); printf("%s\n", ctime(&mTime)); } --- Output from the same machine which gives the python error message Thu Jan 1 00:59:58 1970 Thu Jan 1 00:59:59 1970 Thu Jan 1 01:00:00 1970 -- ___ Python tracker <http://bugs.python.org/issue11850> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com