Re:Released: Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3
by ken on Wednesday April 11, 2012 @11:06PM
(#3830834)
It looks like most of it is in http://hg.python.org/cpython/rev/f4b7ecf8a5f8
[ Parent
| on HN ]
Re:Released: Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3
by bmm6o on Thursday April 12, 2012 @12:25PM
(#3833067)
For anyone else that's curious, it's a pretty simple change:
23.1 --- a/Modules/datetimemodule.c
23.2 +++ b/Modules/datetimemodule.c
23.3 @@ -2566,10 +2566,12 @@ generic_hash(unsigned char *data, int len)
23.4 register long x;
23.5
23.6 p = (unsigned char *) data;
23.7 - x = *p << 7;
23.8 + x = _Py_HashSecret.prefix;
23.9 + x ^= *p << 7;
23.10 while (--len >= 0)
23.11 x = (1000003*x) ^ *p++;
23.12 x ^= len;
23.13 + x ^= _Py_HashSecret.suffix;
23.14 if (x == -1)
23.15 x = -2;
The hash computation is initialized with a global random value, and a second one is xored in at the end. (-1 isn't allowed as a hash, since it's the sentinel value that indicates the hash hasn't been computed yet.)