Message306788
"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. |
|
Date |
User |
Action |
Args |
2017-11-23 08:44:11 | vstinner | set | recipients:
+ vstinner |
2017-11-23 08:44:11 | vstinner | set | messageid: <1511426651.66.0.213398074469.issue32119@psf.upfronthosting.co.za> |
2017-11-23 08:44:11 | vstinner | link | issue32119 messages |
2017-11-23 08:44:11 | vstinner | create | |
|