Index: Modules/timemodule.c =================================================================== --- Modules/timemodule.c (revision 78430) +++ Modules/timemodule.c (working copy) @@ -566,6 +566,10 @@ } else if (!gettmarg(tup, &buf)) return NULL; p = asctime(&buf); + if (p == NULL) { + PyErr_SetString(PyExc_ValueError, "invalid time"); + return NULL; + } if (p[24] == '\n') p[24] = '\0'; return PyString_FromString(p);