mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Patch by Keir Mierle so that sets can be compared to other objects that know
how to compare themselves to sets. (Prep work for making dict views more set-like.)
This commit is contained in:
parent
928115af72
commit
10ab4aeb86
2 changed files with 38 additions and 6 deletions
|
|
@ -1607,12 +1607,8 @@ set_richcompare(PySetObject *v, PyObject *w, int op)
|
|||
PyObject *r1, *r2;
|
||||
|
||||
if(!PyAnySet_Check(w)) {
|
||||
if (op == Py_EQ)
|
||||
Py_RETURN_FALSE;
|
||||
if (op == Py_NE)
|
||||
Py_RETURN_TRUE;
|
||||
PyErr_SetString(PyExc_TypeError, "can only compare to a set");
|
||||
return NULL;
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
switch (op) {
|
||||
case Py_EQ:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue