summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-04-05 18:07:51 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-04-05 18:07:51 (GMT)
commit5e0c2748fb2e16b3b0f33f0bb55f1aaa1272f887 (patch)
tree3d55c3f2739f73ce600270027803ad35fe9f51ba /Objects
parent0c080097088217e350225bed9843dc64204febe7 (diff)
downloadcpython-5e0c2748fb2e16b3b0f33f0bb55f1aaa1272f887.zip
cpython-5e0c2748fb2e16b3b0f33f0bb55f1aaa1272f887.tar.gz
cpython-5e0c2748fb2e16b3b0f33f0bb55f1aaa1272f887.tar.bz2
Use a more robust infinity check in _Py_HashDouble.
This fixes a test_decimal failure on FreeBSD 8.0. (modf apparently doesn't follow C99 Annex F on FreeBSD.)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/object.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 60dc188..8417a99 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1025,15 +1025,15 @@ _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;
fractpart = modf(v, &intpart);
if (fractpart == 0.0) {
/* This must return the same hash as an equal int or long. */
if (intpart > LONG_MAX/2 || -intpart > LONG_MAX/2) {
/* Convert to long and use its hash. */
PyObject *plong; /* converted to Python long */
- if (Py_IS_INFINITY(intpart))
- /* can't convert to long int -- arbitrary */
- v = v < 0 ? -271828.0 : 314159.0;
plong = PyLong_FromDouble(v);
if (plong == NULL)
return -1;