Add a final permutation step to the tuple hash function.
Prevents a collision pattern that occurs with nested tuples.
(Yitz Gale provided code that repeatably demonstrated the weakness.)
diff --git a/Misc/ACKS b/Misc/ACKS
index 6d3ad2c..480a1ec 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -190,6 +190,7 @@
Peter Funk
Geoff Furnish
Lele Gaifax
+Yitzchak Gale
Raymund Galvin
Nitin Ganatra
Fred Gansevles
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index ff20b43..ea7d753 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -280,6 +280,7 @@
x = (x ^ y) * mult;
mult += 82520L + len + len;
}
+ x += 97531L;
if (x == -1)
x = -2;
return x;