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

Skip to content

Commit 7853570

Browse files
committed
Raise ValueError: "unconvertible time" when ctime() returns NULL,
instead of dumping core.
1 parent 1aca4d8 commit 7853570

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Modules/timemodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ time_ctime(self, args)
371371
return NULL;
372372
tt = (time_t)dt;
373373
p = ctime(&tt);
374+
if (p == NULL) {
375+
PyErr_SetString(PyExc_ValueError, "unconvertible time");
376+
return NULL;
377+
}
374378
if (p[24] == '\n')
375379
p[24] = '\0';
376380
return PyString_FromString(p);

0 commit comments

Comments
 (0)