[issue14613] time.time can return NaN

STINNER Victor report at bugs.python.org
Fri Apr 20 01:34:10 CEST 2012


STINNER Victor <victor.stinner at gmail.com> added the comment:

> So NaN is a possible result from time.time()?

Oops. I don't know if it is possible. I just know that it cannot return None :-)

_PyTime_gettimeofday() fills a structure having two integer fields (tv_sec, tv_usec), and floattime() uses these fields to compute a double:

static PyObject*
floattime(void)
{
    _PyTime_timeval t;
    _PyTime_gettimeofday(&t);
    return PyFloat_FromDouble((double)t.tv_sec + t.tv_usec * 1e-6);
}

I don't see how "(double)t.tv_sec + t.tv_usec * 1e-6" can generate NaN.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14613>
_______________________________________


More information about the Python-bugs-list mailing list