[issue32119] test_notify_all() of test_multiprocessing_forkserver failed on Python on x86 Tiger 3.6 with "ValueError: cannot convert float NaN to integer"
STINNER Victor
report at bugs.python.org
Thu Nov 23 03:44:11 EST 2017
STINNER Victor <victor.stinner at gmail.com> added the comment:
"ValueError: cannot convert float NaN to integer": this error occurred on int(float), where the float comes from os.stat()
File "<frozen importlib._bootstrap_external>", line 762, in get_code
Lib/importlib/_bootstrap_external.py:
def get_code(self, fullname):
...
st = self.path_stats(source_path)
...
source_mtime = int(st['mtime']) <~~~~~~ HERE
...
def path_stats(self, path):
st = _path_stat(path)
return {'mtime': st.st_mtime, 'size': st.st_size}
def _path_stat(path):
return _os.stat(path)
=> The float NaN comes from os.stat().st_mtime.
Implementation of os.stat().st_mtime in Modules/posixmodule.c:
static PyObject*
_pystat_fromstructstat(STRUCT_STAT *st)
{
...
#if defined(HAVE_STAT_TV_NSEC)
ansec = st->st_atim.tv_nsec;
mnsec = st->st_mtim.tv_nsec;
cnsec = st->st_ctim.tv_nsec;
#elif defined(HAVE_STAT_TV_NSEC2)
ansec = st->st_atimespec.tv_nsec;
mnsec = st->st_mtimespec.tv_nsec;
cnsec = st->st_ctimespec.tv_nsec;
#elif defined(HAVE_STAT_NSEC)
ansec = st->st_atime_nsec;
mnsec = st->st_mtime_nsec;
cnsec = st->st_ctime_nsec;
#else
ansec = mnsec = cnsec = 0;
#endif
fill_time(v, 7, st->st_atime, ansec);
fill_time(v, 8, st->st_mtime, mnsec);
fill_time(v, 9, st->st_ctime, cnsec);
...
}
static void
fill_time(PyObject *v, int index, time_t sec, unsigned long nsec)
{
...
float_s = PyFloat_FromDouble(sec + 1e-9*nsec); <~~~~~~ HERE
...
PyStructSequence_SET_ITEM(v, index+3, float_s);
...
}
Extract of the ./configure script output:
checking for tv_nsec in struct stat... no
checking for tv_nsec2 in struct stat... yes
=> configure defines HAVE_STAT_TV_NSEC2
We need sec and nsec values from fill_time() to debug this issue.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32119>
_______________________________________
More information about the Python-bugs-list
mailing list