Commit 70b2e1e7 authored by Victor Stinner's avatar Victor Stinner

Issue #14368: _PyTime_gettimeofday() cannot fail

floattime() must not raise an error if the current time is 1970.1.1 at 00:00.
parent a5cf6c49
......@@ -1063,14 +1063,8 @@ static PyObject*
floattime(void)
{
_PyTime_timeval t;
double secs;
_PyTime_gettimeofday(&t);
secs = (double)t.tv_sec + t.tv_usec*0.000001;
if (secs == 0.0) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
return PyFloat_FromDouble(secs);
return PyFloat_FromDouble((double)t.tv_sec + t.tv_usec * 1e-6);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment