diff -r 5b33829badcc Objects/setobject.c --- a/Objects/setobject.c Mon Oct 24 23:49:51 2016 +0300 +++ b/Objects/setobject.c Sun Oct 30 17:55:41 2016 -0500 @@ -26,6 +26,7 @@ #include "Python.h" #include "structmember.h" +#include "pyhash.h" /* Object used as dummy key to fill deleted entries */ static PyObject _dummy_struct; @@ -789,8 +790,10 @@ /* Factor in the number of active entries */ hash ^= ((Py_uhash_t)PySet_GET_SIZE(self) + 1) * 1927868237UL; - /* Disperse patterns arising in nested frozensets */ - hash = hash * 69069U + 907133923UL; + /* Disperse patterns arising in nested frozensets and combinations + of entries with unlucky hashes */ + PyHash_FuncDef * hash_func = PyHash_GetFuncDef(); + hash = (Py_uhash_t)(*hash_func).hash(&hash, sizeof(Py_uhash_t)); /* -1 is reserved as an error code */ if (hash == (Py_uhash_t)-1)