summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-06-10 18:42:15 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-06-10 18:42:15 (GMT)
commit57c2d930f688ca50248241919bd815c85bf39939 (patch)
tree6b233b7dfd1e3ced0697399af4e510673fe849ce /Objects
parentbce036b49ee84333a325a932013592662dbe09d9 (diff)
downloadcpython-57c2d930f688ca50248241919bd815c85bf39939.zip
cpython-57c2d930f688ca50248241919bd815c85bf39939.tar.gz
cpython-57c2d930f688ca50248241919bd815c85bf39939.tar.bz2
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.)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/tupleobject.c1
1 files changed, 1 insertions, 0 deletions
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 @@ tuplehash(PyTupleObject *v)
x = (x ^ y) * mult;
mult += 82520L + len + len;
}
+ x += 97531L;
if (x == -1)
x = -2;
return x;