diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-06-29 23:19:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-29 23:19:32 (GMT) |
commit | f790bc8084d3dfd723889740f9129ac8fcb2fa02 (patch) | |
tree | 00cfbd50d79ed33d31590f65ac34c0945f8e9405 /Objects | |
parent | 02859df10591789c72eb185a4f7dd9cc1ea8dcbb (diff) | |
download | cpython-f790bc8084d3dfd723889740f9129ac8fcb2fa02.zip cpython-f790bc8084d3dfd723889740f9129ac8fcb2fa02.tar.gz cpython-f790bc8084d3dfd723889740f9129ac8fcb2fa02.tar.bz2 |
bpo-44523: Remove the pass-through for hash() in weakref proxy objects (GH-26950) (GH-26960)
(cherry picked from commit e2fea101fd5517f33371b04432842b971021c3bf)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/weakrefobject.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 313e8ab..c36d239 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -732,21 +732,6 @@ static PyMappingMethods proxy_as_mapping = { }; -static Py_hash_t -proxy_hash(PyObject *self) -{ - PyWeakReference *proxy = (PyWeakReference *)self; - if (!proxy_checkref(proxy)) { - return -1; - } - PyObject *obj = PyWeakref_GET_OBJECT(proxy); - Py_INCREF(obj); - Py_hash_t res = PyObject_Hash(obj); - Py_DECREF(obj); - return res; -} - - PyTypeObject _PyWeakref_ProxyType = { PyVarObject_HEAD_INIT(&PyType_Type, 0) @@ -763,7 +748,8 @@ _PyWeakref_ProxyType = { &proxy_as_number, /* tp_as_number */ &proxy_as_sequence, /* tp_as_sequence */ &proxy_as_mapping, /* tp_as_mapping */ - proxy_hash, /* tp_hash */ +// Notice that tp_hash is intentionally omitted as proxies are "mutable" (when the reference dies). + 0, /* tp_hash */ 0, /* tp_call */ proxy_str, /* tp_str */ proxy_getattr, /* tp_getattro */ |