diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-06-21 15:21:14 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-06-21 15:21:14 (GMT) |
commit | 75f94c210a9c270dda64135030a29e7791827473 (patch) | |
tree | b725fb91ca15f54e81b8907f69a399da63d7226a /Modules/datetimemodule.c | |
parent | c56b094bab0728e3a157e2b90047efdd2e817153 (diff) | |
download | cpython-75f94c210a9c270dda64135030a29e7791827473.zip cpython-75f94c210a9c270dda64135030a29e7791827473.tar.gz cpython-75f94c210a9c270dda64135030a29e7791827473.tar.bz2 |
Issue #9005: Prevent utctimetuple() from producing year 0 or year 10,000.
Diffstat (limited to 'Modules/datetimemodule.c')
-rw-r--r-- | Modules/datetimemodule.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c index ddb5a05..8b3cc06 100644 --- a/Modules/datetimemodule.c +++ b/Modules/datetimemodule.c @@ -4932,15 +4932,9 @@ datetime_utctimetuple(PyDateTime_DateTime *self) mm -= offset; stat = normalize_datetime(&y, &m, &d, &hh, &mm, &ss, &us); - if (stat < 0) { - /* At the edges, it's possible we overflowed - * beyond MINYEAR or MAXYEAR. - */ - if (PyErr_ExceptionMatches(PyExc_OverflowError)) - PyErr_Clear(); - else - return NULL; - } + /* OverflowError may be raised in the edge cases. */ + if (stat < 0) + return NULL; } return build_struct_time(y, m, d, hh, mm, ss, 0); } |