Mercurial > cpython-lru_cache-weakref
diff Objects/complexobject.c @ 65603:be8ae6b17539
follow up to #9778: define and use an unsigned hash type
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 Oct 2010 16:20:50 +0000 |
| parents | e8969fb822fc |
| children | ae10282e7f4e |
line wrap: on
line diff
--- a/Objects/complexobject.c Sat Oct 23 01:15:30 2010 +0000 +++ b/Objects/complexobject.c Sat Oct 23 16:20:50 2010 +0000 @@ -397,12 +397,12 @@ static Py_hash_t complex_hash(PyComplexObject *v) { - unsigned long hashreal, hashimag, combined; - hashreal = (unsigned long)_Py_HashDouble(v->cval.real); - if (hashreal == (unsigned long)-1) + Py_uhash_t hashreal, hashimag, combined; + hashreal = (Py_uhash_t)_Py_HashDouble(v->cval.real); + if (hashreal == (Py_uhash_t)-1) return -1; - hashimag = (unsigned long)_Py_HashDouble(v->cval.imag); - if (hashimag == (unsigned long)-1) + hashimag = (Py_uhash_t)_Py_HashDouble(v->cval.imag); + if (hashimag == (Py_uhash_t)-1) return -1; /* Note: if the imaginary part is 0, hashimag is 0 now, * so the following returns hashreal unchanged. This is @@ -411,8 +411,8 @@ * hash(x + 0*j) must equal hash(x). */ combined = hashreal + _PyHASH_IMAG * hashimag; - if (combined == (unsigned long)-1) - combined = (unsigned long)-2; + if (combined == (Py_uhash_t)-1) + combined = (Py_uhash_t)-2; return (Py_hash_t)combined; }
