summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-02-20 23:33:36 (GMT)
committerGeorg Brandl <georg@python.org>2012-02-20 23:33:36 (GMT)
commit2fb477c0f0284439d40cb3f46eea45ef42446e53 (patch)
treec8df3747d511256d56ca4af046db7915b5c06096 /Objects/unicodeobject.c
parentb5c793a0b349cb02003433c30a410595b224079f (diff)
parent9edceb3e591063f382ae82e14313813ffc1af0bf (diff)
downloadcpython-2fb477c0f0284439d40cb3f46eea45ef42446e53.zip
cpython-2fb477c0f0284439d40cb3f46eea45ef42446e53.tar.gz
cpython-2fb477c0f0284439d40cb3f46eea45ef42446e53.tar.bz2
Merge 3.2: Issue #13703 plus some related test suite fixes.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 07d3eb8..716ca3f 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -11221,11 +11221,12 @@ unicode_hash(PyObject *self)
len = PyUnicode_GET_LENGTH(self);
/* The hash function as a macro, gets expanded three times below. */
-#define HASH(P) \
- x = (Py_uhash_t)*P << 7; \
- while (--len >= 0) \
- x = (_PyHASH_MULTIPLIER*x) ^ (Py_uhash_t)*P++;
+#define HASH(P) \
+ x ^= (Py_uhash_t) *P << 7; \
+ while (--len >= 0) \
+ x = (_PyHASH_MULTIPLIER * x) ^ (Py_uhash_t) *P++; \
+ x = (Py_uhash_t) _Py_HashSecret.prefix;
switch (PyUnicode_KIND(self)) {
case PyUnicode_1BYTE_KIND: {
const unsigned char *c = PyUnicode_1BYTE_DATA(self);
@@ -11246,7 +11247,8 @@ unicode_hash(PyObject *self)
break;
}
}
- x ^= (Py_uhash_t)PyUnicode_GET_LENGTH(self);
+ x ^= (Py_uhash_t) PyUnicode_GET_LENGTH(self);
+ x ^= (Py_uhash_t) _Py_HashSecret.suffix;
if (x == -1)
x = -2;