Issue #1621: Fix undefined behaviour in bytes.__hash__, str.__hash__, tuple.__hash__, frozenset.__hash__ and set indexing operations.
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index cdc27ab..e76e508 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -418,7 +418,7 @@
mp->ma_lookup = lookdict;
return lookdict(mp, key, hash);
}
- i = hash & mask;
+ i = (size_t)hash & mask;
ep = &ep0[i];
if (ep->me_key == NULL || ep->me_key == key)
return ep;
@@ -572,7 +572,7 @@
register PyDictEntry *ep;
MAINTAIN_TRACKING(mp, key, value);
- i = hash & mask;
+ i = (size_t)hash & mask;
ep = &ep0[i];
for (perturb = hash; ep->me_key != NULL; perturb >>= PERTURB_SHIFT) {
i = (i << 2) + i + perturb + 1;