mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Raise ValueError: "unconvertible time" when ctime() returns NULL,
instead of dumping core.
This commit is contained in:
parent
1aca4d803d
commit
7853570651
1 changed files with 4 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue