diff -r 79e5bb0d9b8e Modules/timemodule.c --- a/Modules/timemodule.c Tue Feb 18 09:37:43 2014 +0100 +++ b/Modules/timemodule.c Tue Feb 18 10:18:21 2014 +0100 @@ -381,10 +381,19 @@ If the platform supports the tm_gmtoff a attributes only."); static int -pylocaltime(time_t *timep, struct tm *result) +pylocaltime(time_t *timep, struct tm *result, const char *funcname) { struct tm *local; +#ifdef _AIX + if (*timep < 0) { + PyErr_Format(PyExc_OverflowError, + "%s() timestamp argument out of range", + funcname); + return -1; + } +#endif + assert (timep != NULL); local = localtime(timep); if (local == NULL) { @@ -408,7 +417,7 @@ time_localtime(PyObject *self, PyObject if (!parse_time_t_args(args, "|O:localtime", &when)) return NULL; - if (pylocaltime(&when, &buf) == -1) + if (pylocaltime(&when, &buf, "localtime") == -1) return NULL; return tmtotuple(&buf); } @@ -592,7 +601,7 @@ time_strftime(PyObject *self, PyObject * if (tup == NULL) { time_t tt = time(NULL); - if (pylocaltime(&tt, &buf) == -1) + if (pylocaltime(&tt, &buf, "strftime") == -1) return NULL; } else if (!gettmarg(tup, &buf) || !checktm(&buf)) @@ -781,7 +790,7 @@ time_asctime(PyObject *self, PyObject *a return NULL; if (tup == NULL) { time_t tt = time(NULL); - if (pylocaltime(&tt, &buf) == -1) + if (pylocaltime(&tt, &buf, "asctime") == -1) return NULL; } else if (!gettmarg(tup, &buf) || !checktm(&buf)) @@ -803,7 +812,7 @@ time_ctime(PyObject *self, PyObject *arg struct tm buf; if (!parse_time_t_args(args, "|O:ctime", &tt)) return NULL; - if (pylocaltime(&tt, &buf) == -1) + if (pylocaltime(&tt, &buf, "ctime") == -1) return NULL; return _asctime(&buf); }