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.
This commit is contained in:
Tim Peters 2000-08-15 03:34:48 +00:00
parent 7aced17437
commit 39dce29365
5 changed files with 83 additions and 101 deletions

View file

@ -114,7 +114,7 @@ PyLong_FromDouble(double dval)
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;