diff Objects/longobject.c @ 13976:5ada9fa54801 legacy-trunk

Fix for http://sourceforge.net/bugs/?func=detailbug&bug_id=111866&group_id=5470. This was a misleading bug -- the true "bug" was that hash(x) gave an error return when x is an infinity. Fixed that. Added new Py_IS_INFINITY macro to pyport.h. Rearranged code to reduce growing duplication in hashing of float and complex numbers, pushing Trent's earlier stab at that to a logical conclusion. Fixed exceedingly rare bug where hashing of floats could return -1 even if there wasn't an error (didn't waste time trying to construct a test case, it was simply obvious from the code that it *could* happen). Improved complex hash so that hash(complex(x, y)) doesn't systematically equal hash(complex(y, x)) anymore.
author Tim Peters <tim.peters@gmail.com>
date Tue, 15 Aug 2000 03:34:48 +0000
parents 59f8cedcf049
children 6f6f965c5e2d
line wrap: on
line diff
--- a/Objects/longobject.c	Tue Aug 15 01:13:23 2000 +0000
+++ b/Objects/longobject.c	Tue Aug 15 03:34:48 2000 +0000
@@ -114,7 +114,7 @@
 	double frac;
 	int i, ndig, expo, neg;
 	neg = 0;
-	if (dval && dval * 0.5 == dval) {
+	if (Py_IS_INFINITY(dval)) {
 		PyErr_SetString(PyExc_OverflowError,
 			"cannot convert float infinity to long");
 		return NULL;