]> granicus.if.org Git - python/commitdiff
Use a better NaN test in _Py_HashDouble as well.
authorMark Dickinson <dickinsm@gmail.com>
Mon, 5 Apr 2010 18:54:51 +0000 (18:54 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Mon, 5 Apr 2010 18:54:51 +0000 (18:54 +0000)
Objects/object.c

index 8417a993aba8cfcae1654eff3a81382db74fd8b2..cf8a5509f05489310702d389ee8268cd040d568b 100644 (file)
@@ -1025,9 +1025,12 @@ _Py_HashDouble(double v)
         * of mapping keys will turn out weird.
         */
 
-       if (Py_IS_INFINITY(v))
-               /* can't convert to long int -- arbitrary */
-               v = v < 0 ? -271828.0 : 314159.0;
+       if (!Py_IS_FINITE(v)) {
+               if (Py_IS_INFINITY(v))
+                       return v < 0 ? -271828 : 314159;
+               else
+                       return 0;
+       }
        fractpart = modf(v, &intpart);
        if (fractpart == 0.0) {
                /* This must return the same hash as an equal int or long. */