Raise ValueError: "unconvertible time" when ctime() returns NULL,

instead of dumping core.
This commit is contained in:
Guido van Rossum 1998-03-03 22:19:10 +00:00
parent 1aca4d803d
commit 7853570651

View file

@ -371,6 +371,10 @@ time_ctime(self, args)
return NULL;
tt = (time_t)dt;
p = ctime(&tt);
if (p == NULL) {
PyErr_SetString(PyExc_ValueError, "unconvertible time");
return NULL;
}
if (p[24] == '\n')
p[24] = '\0';
return PyString_FromString(p);