Mercurial > cpython-lru_cache-weakref
diff Objects/longobject.c @ 28032:53bef20f84cc legacy-trunk
Fix SF bug #689659, 64-bit int and long hash keys incompatible
On a 64-bit machine, a dictionary could contain duplicate int/long keys
if the value was > 2**32.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sun, 23 Feb 2003 23:11:41 +0000 |
| parents | 6205da383e4c |
| children | 871da703e4c0 |
line wrap: on
line diff
--- a/Objects/longobject.c Sun Feb 23 22:59:01 2003 +0000 +++ b/Objects/longobject.c Sun Feb 23 23:11:41 2003 +0000 @@ -1490,11 +1490,13 @@ sign = -1; i = -(i); } +#define LONG_BIT_SHIFT (8*sizeof(long) - SHIFT) while (--i >= 0) { - /* Force a 32-bit circular shift */ - x = ((x << SHIFT) & ~MASK) | ((x >> (32-SHIFT)) & MASK); + /* Force a native long #-bits (32 or 64) circular shift */ + x = ((x << SHIFT) & ~MASK) | ((x >> LONG_BIT_SHIFT) & MASK); x += v->ob_digit[i]; } +#undef LONG_BIT_SHIFT x = x * sign; if (x == -1) x = -2;
