summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-06-28 09:54:58 (GMT)
committerGitHub <noreply@github.com>2022-06-28 09:54:58 (GMT)
commitefdc9d68de84410b468c2dc87b371b4c3d0663ac (patch)
tree6b2e816555b591cdbc21070fb75283d26b40d25f /Objects
parent71d5299b73c854a7b0e12eb5d0a524579723660b (diff)
downloadcpython-efdc9d68de84410b468c2dc87b371b4c3d0663ac.zip
cpython-efdc9d68de84410b468c2dc87b371b4c3d0663ac.tar.gz
cpython-efdc9d68de84410b468c2dc87b371b4c3d0663ac.tar.bz2
gh-87995: Make MappingProxyType hashable (GH-94252)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/descrobject.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 8ef6a82..82570e0 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1178,6 +1178,12 @@ mappingproxy_getiter(mappingproxyobject *pp)
return PyObject_GetIter(pp->mapping);
}
+static Py_hash_t
+mappingproxy_hash(mappingproxyobject *pp)
+{
+ return PyObject_Hash(pp->mapping);
+}
+
static PyObject *
mappingproxy_str(mappingproxyobject *pp)
{
@@ -1901,7 +1907,7 @@ PyTypeObject PyDictProxy_Type = {
&mappingproxy_as_number, /* tp_as_number */
&mappingproxy_as_sequence, /* tp_as_sequence */
&mappingproxy_as_mapping, /* tp_as_mapping */
- 0, /* tp_hash */
+ (hashfunc)mappingproxy_hash, /* tp_hash */
0, /* tp_call */
(reprfunc)mappingproxy_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */