summaryrefslogtreecommitdiffstats
path: root/Objects
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 /Objects
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 'Objects')
-rw-r--r--Objects/classobject.c2
-rw-r--r--Objects/descrobject.c2
-rw-r--r--Objects/methodobject.c2
-rw-r--r--Objects/typeobject.c8
4 files changed, 4 insertions, 10 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index d7e520f..9cbb944 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -301,7 +301,7 @@ static Py_hash_t
method_hash(PyMethodObject *a)
{
Py_hash_t x, y;
- x = _Py_HashPointer(a->im_self);
+ x = PyObject_GenericHash(a->im_self);
y = PyObject_Hash(a->im_func);
if (y == -1)
return -1;
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index df546a0..3423f15 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1346,7 +1346,7 @@ wrapper_hash(PyObject *self)
{
wrapperobject *wp = (wrapperobject *)self;
Py_hash_t x, y;
- x = _Py_HashPointer(wp->self);
+ x = PyObject_GenericHash(wp->self);
y = _Py_HashPointer(wp->descr);
x = x ^ y;
if (x == -1)
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 599fb05..d6773a2 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -320,7 +320,7 @@ static Py_hash_t
meth_hash(PyCFunctionObject *a)
{
Py_hash_t x, y;
- x = _Py_HashPointer(a->m_self);
+ x = PyObject_GenericHash(a->m_self);
y = _Py_HashPointer((void*)(a->m_ml->ml_meth));
x ^= y;
if (x == -1)
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 06c2fc8..8282278 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -6891,12 +6891,6 @@ PyDoc_STRVAR(object_doc,
"When called, it accepts no arguments and returns a new featureless\n"
"instance that has no instance attributes and cannot be given any.\n");
-static Py_hash_t
-object_hash(PyObject *obj)
-{
- return _Py_HashPointer(obj);
-}
-
PyTypeObject PyBaseObject_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"object", /* tp_name */
@@ -6911,7 +6905,7 @@ PyTypeObject PyBaseObject_Type = {
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
- object_hash, /* tp_hash */
+ PyObject_GenericHash, /* tp_hash */
0, /* tp_call */
object_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */