Mercurial > cpython-lru_cache-weakref
diff Objects/tupleobject.c @ 72464:698fa089ce70
Issue #1621: Fix undefined behaviour in bytes.__hash__, str.__hash__, tuple.__hash__, frozenset.__hash__ and set indexing operations.
| author | Mark Dickinson <mdickinson@enthought.com> |
|---|---|
| date | Sat, 24 Sep 2011 18:18:40 +0100 |
| parents | d0b0fcbb40db |
| children | 656c13024ede |
line wrap: on
line diff
--- a/Objects/tupleobject.c Sat Sep 24 16:24:56 2011 +0100 +++ b/Objects/tupleobject.c Sat Sep 24 18:18:40 2011 +0100 @@ -315,11 +315,12 @@ static Py_hash_t tuplehash(PyTupleObject *v) { - register Py_hash_t x, y; + register Py_uhash_t x; + register Py_hash_t y; register Py_ssize_t len = Py_SIZE(v); register PyObject **p; - Py_hash_t mult = 1000003L; - x = 0x345678L; + Py_uhash_t mult = 1000003; + x = 0x345678; p = v->ob_item; while (--len >= 0) { y = PyObject_Hash(*p++); @@ -330,7 +331,7 @@ mult += (Py_hash_t)(82520L + len + len); } x += 97531L; - if (x == -1) + if (x == (Py_uhash_t)-1) x = -2; return x; }
