[Python-checkins] r79809 - python/trunk/Objects/object.c

mark.dickinson python-checkins at python.org
Mon Apr 5 20:54:51 CEST 2010


Author: mark.dickinson
Date: Mon Apr  5 20:54:51 2010
New Revision: 79809

Log:
Use a better NaN test in _Py_HashDouble as well.

Modified:
   python/trunk/Objects/object.c

Modified: python/trunk/Objects/object.c
==============================================================================
--- python/trunk/Objects/object.c	(original)
+++ python/trunk/Objects/object.c	Mon Apr  5 20:54:51 2010
@@ -1025,9 +1025,12 @@
 	 * 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. */


More information about the Python-checkins mailing list