summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapi
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-03-22 18:19:10 (GMT)
committerGitHub <noreply@github.com>2024-03-22 18:19:10 (GMT)
commite2e0b4b4b92694ba894e02b4a66fd87c166ed10f (patch)
tree5ed883afb7db70957444e4df8adca74af54eef17 /Modules/_testcapi
parent567ab3bd15398c8c7b791f3e376ae3e3c0bbe079 (diff)
downloadcpython-e2e0b4b4b92694ba894e02b4a66fd87c166ed10f.zip
cpython-e2e0b4b4b92694ba894e02b4a66fd87c166ed10f.tar.gz
cpython-e2e0b4b4b92694ba894e02b4a66fd87c166ed10f.tar.bz2
gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)
Diffstat (limited to 'Modules/_testcapi')
-rw-r--r--Modules/_testcapi/hash.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Modules/_testcapi/hash.c b/Modules/_testcapi/hash.c
index aee7678..809d537 100644
--- a/Modules/_testcapi/hash.c
+++ b/Modules/_testcapi/hash.c
@@ -59,9 +59,20 @@ hash_pointer(PyObject *Py_UNUSED(module), PyObject *arg)
}
+static PyObject *
+object_generichash(PyObject *Py_UNUSED(module), PyObject *arg)
+{
+ NULLABLE(arg);
+ Py_hash_t hash = PyObject_GenericHash(arg);
+ Py_BUILD_ASSERT(sizeof(long long) >= sizeof(hash));
+ return PyLong_FromLongLong(hash);
+}
+
+
static PyMethodDef test_methods[] = {
{"hash_getfuncdef", hash_getfuncdef, METH_NOARGS},
{"hash_pointer", hash_pointer, METH_O},
+ {"object_generichash", object_generichash, METH_O},
{NULL},
};