diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-04-05 18:54:51 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-04-05 18:54:51 (GMT) |
commit | 56506a6ed2380cddc0e70d2df254ce4724b43629 (patch) | |
tree | 0713390dc9ecdc9c9e33297ee80d48981b45921f /Objects/object.c | |
parent | e1d665a90e4a20a60c0c9904417160ea3c7660b7 (diff) | |
download | cpython-56506a6ed2380cddc0e70d2df254ce4724b43629.zip cpython-56506a6ed2380cddc0e70d2df254ce4724b43629.tar.gz cpython-56506a6ed2380cddc0e70d2df254ce4724b43629.tar.bz2 |
Use a better NaN test in _Py_HashDouble as well.
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 9 |
1 files 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. */ |