Skip to content

Commit 70b2e1e

Browse files
committed
Issue #14368: _PyTime_gettimeofday() cannot fail
floattime() must not raise an error if the current time is 1970.1.1 at 00:00.
1 parent a5cf6c4 commit 70b2e1e

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

Modules/timemodule.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,14 +1063,8 @@ static PyObject*
10631063
floattime(void)
10641064
{
10651065
_PyTime_timeval t;
1066-
double secs;
10671066
_PyTime_gettimeofday(&t);
1068-
secs = (double)t.tv_sec + t.tv_usec*0.000001;
1069-
if (secs == 0.0) {
1070-
PyErr_SetFromErrno(PyExc_OSError);
1071-
return NULL;
1072-
}
1073-
return PyFloat_FromDouble(secs);
1067+
return PyFloat_FromDouble((double)t.tv_sec + t.tv_usec * 1e-6);
10741068
}
10751069

10761070

0 commit comments

Comments
 (0)