From 56506a6ed2380cddc0e70d2df254ce4724b43629 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Mon, 5 Apr 2010 18:54:51 +0000 Subject: Use a better NaN test in _Py_HashDouble as well. --- Objects/object.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Objects/object.c b/Objects/object.c index 8417a99..cf8a550 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -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. */ -- cgit v0.12