Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ac4261

Browse files
committed
Issue #19748: On AIX, time.mktime() now raises an OverflowError for year
outsize range [1902; 2037].
1 parent 24a882b commit 1ac4261

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

Lib/test/test_time.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def test_ctime(self):
228228
self.assertEqual(time.ctime(t), 'Sun Sep 16 01:03:52 1973')
229229
t = time.mktime((2000, 1, 1, 0, 0, 0, 0, 0, -1))
230230
self.assertEqual(time.ctime(t), 'Sat Jan 1 00:00:00 2000')
231-
for year in [-100, 100, 1000, 2000, 10000]:
231+
for year in [-100, 100, 1000, 2000, 2050, 10000]:
232232
try:
233233
testval = time.mktime((year, 1, 10) + (0,)*6)
234234
except (ValueError, OverflowError):

Misc/NEWS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
Python News
33
+++++++++++
44

5+
What's New in Python 3.4.1?
6+
===========================
7+
8+
Library
9+
-------
10+
11+
- Issue #19748: On AIX, time.mktime() now raises an OverflowError for year
12+
outsize range [1902; 2037].
13+
14+
515
What's New in Python 3.4.0 release candidate 2?
616
===============================================
717

Modules/timemodule.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,18 @@ time_mktime(PyObject *self, PyObject *tup)
823823
time_t tt;
824824
if (!gettmarg(tup, &buf))
825825
return NULL;
826+
#ifdef _AIX
827+
/* year < 1902 or year > 2037 */
828+
if (buf.tm_year < 2 || buf.tm_year > 137) {
829+
/* Issue #19748: On AIX, mktime() doesn't report overflow error for
830+
* timestamp < -2^31 or timestamp > 2**31-1. */
831+
PyErr_SetString(PyExc_OverflowError,
832+
"mktime argument out of range");
833+
return NULL;
834+
}
835+
#else
826836
buf.tm_wday = -1; /* sentinel; original value ignored */
837+
#endif
827838
tt = mktime(&buf);
828839
/* Return value of -1 does not necessarily mean an error, but tm_wday
829840
* cannot remain set to -1 if mktime succeeded. */

0 commit comments

Comments
 (0)