classification
Title: ValueError: cannot convert float NaN to integer
Type: compile error Stage: resolved
Components: Build Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: dbr, mark.dickinson, shivam_python_issues, terry.reedy, vstinner
Priority: normal Keywords:

Created on 2012-02-10 11:43 by shivam_python_issues, last changed 2019-10-22 23:22 by vstinner. This issue is now closed.

Messages (10)
msg153039 - (view) Author: Shivam (shivam_python_issues) Date: 2012-02-10 11:43
Hi Team,
   Kindly help me in resolving below issue which arises when we do "make install" as it is show stopper for us.

Listing /usr/local/lib/python2.7 ...
Compiling /usr/local/lib/python2.7/BaseHTTPServer.py ...
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/compileall.py", line 213, in <module>
    exit_status = int(not main())
  File "/usr/local/lib/python2.7/compileall.py", line 200, in main
    force, rx, quiet):
  File "/usr/local/lib/python2.7/compileall.py", line 50, in compile_dir
    if not compile_file(fullname, ddir, force, rx, quiet):
  File "/usr/local/lib/python2.7/compileall.py", line 99, in compile_file
    ok = py_compile.compile(fullname, None, dfile, True)
  File "/usr/local/lib/python2.7/py_compile.py", line 108, in compile
    timestamp = long(os.fstat(f.fileno()).st_mtime)
ValueError: cannot convert float NaN to integer
make: *** [libinstall] Error 1


Addtionaly:
-----------
At the time of make below message is flashed as well:

Failed to build these modules:
datetime           dbm
msg153040 - (view) Author: Shivam (shivam_python_issues) Date: 2012-02-10 12:00
Hi Team,
   I am having this issue on mips 64bit machine running debian.

Regards
Shivam Agarwal
msg153172 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-02-12 04:53
If I believe the error message, os.fstat(f.fileno()).st_mtime is returning a NaN, which would be a bug in our function or your system. Since os.fstat should be a thin wrapper over the system call, I would lean to the latter. I do not know if writing to sys.stderr would work during compilation, but if it does, try inserting a statement to grab the value and print it before the long conversion.

Is this error 'deterministic' in being raised consistently?
msg153262 - (view) Author: Shivam (shivam_python_issues) Date: 2012-02-13 12:02
Hi Terry,
  Thanks for your reply.

  I am made changes suggested by you but still getting the same error:

  Below is the change that have been made:

        try:
            local_var = (os.fstat(f.fileno()).st_mtime) --> added line
            print "Value of local_var",local_var --> added line
            timestamp = long(os.fstat(f.fileno()).st_mtime)

Regards
Shivam Agarwal
msg153266 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-02-13 13:07
It's going to be tricky for any of the core Python developers to solve this based on the current level of information---unless anyone has access to a MIPs machine and can reproduce the error, that is.  Can you find a local expert who knows C to look into the issue?  The most relevant file is probably Modules/posixmodule.c.

Things to look at:

- do the stat-related values in pyconfig.h (which is generated at configure time) look correct for your platform?  Perhaps if you attach a copy of the pyconfig.h file produced at build time that could help.

- are there any relevant warnings or errors at compile time?  E.g., is there any compiler output near the point where Modules/posixmodule.c is defined?  Can you look back at the 'make' output and find out why the 'datetime' module failed to build?

What was the output from the 'print' statement that Terry suggested you add?
msg153465 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2012-02-16 08:08
FYI - A "similar" NaN appearing in an unexpected place (the random module in this case) bug that I just filed - http://bugs.python.org/issue14028.

I don't actually know if these will be related or not.
msg153472 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-02-16 10:27
My guess would be not related.  My best guess for this issue is that it's caused by some mismatch in the struct stat declarations / uses on MIPS / Linux.  A Google search for MIPS and stat suggests that there are problems in this area.
msg288995 - (view) Author: David Robins (dbr) Date: 2017-03-04 22:41
I saw a similar error with Python 3.6 on a MIPS (32-bit - mipsisa32r2el-axis-linux-gnu) platform, but during interpreter startup, not install (perhaps because it was cross-compiled so install on the host doesn't run the target Python). It was due to building with a hard-float compiler when soft-float was needed (GCC 6.3.0, worked with --with-float=soft). Full error:

Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 762, in get_code
ValueError: cannot convert float NaN to integer

Program received signal SIGABRT, Aborted.
msg306791 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-23 08:49
See also bpo-32119.
msg355178 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-22 23:22
The issue has not been seen since 2017-03-04, I close the issue as out of date.
History
Date User Action Args
2019-10-22 23:22:02vstinnersetstatus: open -> closed
resolution: out of date
messages: + msg355178

stage: resolved
2017-11-23 16:56:25gregory.p.smithsetnosy: - gregory.p.smith
2017-11-23 08:49:46vstinnersetmessages: + msg306791
2017-03-04 22:41:42dbrsetnosy: + dbr
messages: + msg288995
2012-02-16 10:27:08mark.dickinsonsetmessages: + msg153472
2012-02-16 08:09:00gregory.p.smithsetnosy: + gregory.p.smith
messages: + msg153465
2012-02-13 13:07:33mark.dickinsonsetmessages: + msg153266
2012-02-13 12:02:48shivam_python_issuessetmessages: + msg153262
2012-02-12 04:53:32terry.reedysetnosy: + terry.reedy
messages: + msg153172
2012-02-10 13:20:48mark.dickinsonsetnosy: + mark.dickinson
2012-02-10 12:00:11shivam_python_issuessetmessages: + msg153040
2012-02-10 11:57:44ezio.melottisetnosy: + vstinner
2012-02-10 11:43:57shivam_python_issuescreate