diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2011-01-11 01:21:25 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2011-01-11 01:21:25 (GMT) |
commit | b7d40d170248fb2419d068c6b0647ed262e3427f (patch) | |
tree | 371979019361255b821b548001f2e24821bce658 /Modules/timemodule.c | |
parent | 723447958070683deb3ff32d793c4bb731d325b7 (diff) | |
download | cpython-b7d40d170248fb2419d068c6b0647ed262e3427f.zip cpython-b7d40d170248fb2419d068c6b0647ed262e3427f.tar.gz cpython-b7d40d170248fb2419d068c6b0647ed262e3427f.tar.bz2 |
Issue #1726687: time.mktime() will now correctly compute value one
second before epoch. Original patch by Peter Wang, reported by Martin
Blais.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 2286006..3a12522 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -694,8 +694,11 @@ time_mktime(PyObject *self, PyObject *tup) time_t tt; if (!gettmarg(tup, &buf)) return NULL; + buf.tm_wday = -1; /* sentinel; original value ignored */ tt = mktime(&buf); - if (tt == (time_t)(-1)) { + /* 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; |