static PyObject * parser_richcompare(PyObject *left, PyObject *right, int op) { int result; /* neither argument should be NULL, unless something's gone wrong */ if (left == NULL || right == NULL) { PyErr_BadInternalCall(); return NULL; } /* both arguments should be instances of PyST_Object */ if (!PyST_Object_Check(left) || !PyST_Object_Check(right)) { Py_RETURN_NOTIMPLEMENTED; } if (left == right) /* if arguments are identical, they're equal */ result = 0; else result = parser_compare_nodes(((PyST_Object *)left)->st_node, ((PyST_Object *)right)->st_node); Py_RETURN_RICHCOMPARE(result, 0, op); }
static PyObject * cell_richcompare(PyObject *a, PyObject *b, int op) { /* neither argument should be NULL, unless something's gone wrong */ assert(a != NULL && b != NULL); /* both arguments should be instances of PyCellObject */ if (!PyCell_Check(a) || !PyCell_Check(b)) { Py_RETURN_NOTIMPLEMENTED; } /* compare cells by contents; empty cells come before anything else */ a = ((PyCellObject *)a)->ob_ref; b = ((PyCellObject *)b)->ob_ref; if (a != NULL && b != NULL) return PyObject_RichCompare(a, b, op); Py_RETURN_RICHCOMPARE(b == NULL, a == NULL, op); }