make hashes always the size of pointers; introduce Py_hash_t #9778
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index ece2a37..4604519 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1148,12 +1148,12 @@
static PyObject *
builtin_hash(PyObject *self, PyObject *v)
{
- long x;
+ Py_hash_t x;
x = PyObject_Hash(v);
if (x == -1)
return NULL;
- return PyLong_FromLong(x);
+ return PyLong_FromSsize_t(x);
}
PyDoc_STRVAR(hash_doc,
diff --git a/Python/ceval.c b/Python/ceval.c
index f85f33a..1eb5f62 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2102,7 +2102,7 @@
/* Inline the PyDict_GetItem() calls.
WARNING: this is an extreme speed hack.
Do not try this at home. */
- long hash = ((PyUnicodeObject *)w)->hash;
+ Py_hash_t hash = ((PyUnicodeObject *)w)->hash;
if (hash != -1) {
PyDictObject *d;
PyDictEntry *e;
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 6c563f0..033c9d5 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -567,7 +567,7 @@
if (hash_info == NULL)
return NULL;
PyStructSequence_SET_ITEM(hash_info, field++,
- PyLong_FromLong(8*sizeof(long)));
+ PyLong_FromLong(8*sizeof(Py_hash_t)));
PyStructSequence_SET_ITEM(hash_info, field++,
PyLong_FromLong(_PyHASH_MODULUS));
PyStructSequence_SET_ITEM(hash_info, field++,