Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
report OverflowError for 2038 issue on VxWorks
  • Loading branch information
pxinwr committed Apr 2, 2019
commit 219af22df1ac48597b2b0ee631a7f99b8b46af82
8 changes: 1 addition & 7 deletions Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,7 @@ def test_ctime(self):
self.assertEqual(time.ctime(t), 'Sun Sep 16 01:03:52 1973')
t = time.mktime((2000, 1, 1, 0, 0, 0, 0, 0, -1))
self.assertEqual(time.ctime(t), 'Sat Jan 1 00:00:00 2000')
# the largest year on VxWorks is 2038
if 'vxworks' in sys.platform :
range = [-100, 100, 1000, 2000]
else:
range = [-100, 100, 1000, 2000, 2050, 10000]

for year in range:
for year in [-100, 100, 1000, 2000, 2050, 10000]:
try:
testval = time.mktime((year, 1, 10) + (0,)*6)
except (ValueError, OverflowError):
Expand Down
15 changes: 10 additions & 5 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,18 +1005,23 @@ time_mktime(PyObject *self, PyObject *tup)
{
return NULL;
}
#ifndef _AIX
buf.tm_wday = -1; /* sentinel; original value ignored */
tt = mktime(&buf);
#else

#if defined(_AIX) || (defined(__VXWORKS__) && !defined(_WRS_CONFIG_LP64))
Comment thread
pxinwr marked this conversation as resolved.
/* year < 1902 or year > 2037 */
if ((buf.tm_year < 2) || (buf.tm_year > 137)) {
/* Issue #19748: On AIX, mktime() doesn't report overflow error for
* timestamp < -2^31 or timestamp > 2**31-1. */
* timestamp < -2^31 or timestamp > 2**31-1. VxWorks has the same
* issue when working in 32 bit mode. */
PyErr_SetString(PyExc_OverflowError,
"mktime argument out of range");
return NULL;
}
#endif

#ifndef _AIX
Comment thread
pxinwr marked this conversation as resolved.
Outdated
buf.tm_wday = -1; /* sentinel; original value ignored */
tt = mktime(&buf);
#else
year = buf.tm_year;
/* year < 1970 - adjust buf.tm_year into legal range */
while (buf.tm_year < 70) {
Expand Down