[issue1481296] long(float('nan'))!=0L

Mark Dickinson report at bugs.python.org
Mon Jul 21 23:56:37 CEST 2008


Mark Dickinson <dickinsm at gmail.com> added the comment:

I still think this is the wrong solution, and should be fixed before 2.6; 
long(float('nan')) should raise ValueError.  As Alexander points out, 
this fits much better with the IEEE 754 standard, and also with the C99 
standard.  It also just "feels right", to me; an attempt to convert a nan 
to an integer should not pass silently.

Here's a patch, based on Ronald's original patch.

Christian, what was the motivation for returning 0 here?

(One could also argue on the basis of IEEE 754 and C99 that 
long(float('inf')) should raise ValueError instead of OverflowError;  
personally, I'm content that long(float('inf')) raises an exception---I'm 
not too bothered which one.)

I agree that there doesn't seem much value in backporting the fix.

----------
keywords: +patch
Added file: http://bugs.python.org/file10957/issue1481296.patch

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


More information about the Python-bugs-list mailing list