summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-04-05 18:54:51 +0000
committerMark Dickinson <dickinsm@gmail.com>2010-04-05 18:54:51 +0000
commit9cf55cbc6d246ca11b637813cb2d3beee8d8ebf4 (patch)
tree30d0d5dc41ff4766cb8daf6eb5c00ba5f95eb732 /Objects
parente327ff6d7b69eb9758b365df4674b3d36792204f (diff)
downloadcpython-9cf55cbc6d246ca11b637813cb2d3beee8d8ebf4.tar.gz
Use a better NaN test in _Py_HashDouble as well.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/object.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 8417a993ab..cf8a5509f0 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. */