mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #16453: Fix equality testing of dead weakref objects.
Also add tests for ordering and hashing.
This commit is contained in:
parent
19e568d254
commit
e11fecb5a9
3 changed files with 93 additions and 24 deletions
|
@ -195,9 +195,13 @@ weakref_richcompare(PyWeakReference* self, PyWeakReference* other, int op)
|
|||
}
|
||||
if (PyWeakref_GET_OBJECT(self) == Py_None
|
||||
|| PyWeakref_GET_OBJECT(other) == Py_None) {
|
||||
PyObject *res = self==other ? Py_True : Py_False;
|
||||
Py_INCREF(res);
|
||||
return res;
|
||||
int res = (self == other);
|
||||
if (op == Py_NE)
|
||||
res = !res;
|
||||
if (res)
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
return PyObject_RichCompare(PyWeakref_GET_OBJECT(self),
|
||||
PyWeakref_GET_OBJECT(other), op);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue