Skip to content

Commit 242be92

Browse files
committed
Revert to original do_richcompare
1 parent 6e6d47a commit 242be92

File tree

1 file changed

+7
-11
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+7
-11
lines changed

graalpython/com.oracle.graal.python.cext/src/object.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,26 +231,22 @@ do_richcompare(PyObject *v, PyObject *w, int op)
231231
PyObject *res;
232232
int checked_reverse_op = 0;
233233

234-
/* GraalPy change: in the following, we replaced any 'Py_TYPE(v)' by
235-
'v_type' and any 'Py_TYPE(w)' by 'w_type' to save some calls. */
236-
const PyTypeObject *v_type = Py_TYPE(v);
237-
const PyTypeObject *w_type = Py_TYPE(w);
238-
if (v_type != w_type &&
239-
PyType_IsSubtype(w_type, v_type) &&
240-
(f = w_type->tp_richcompare) != NULL) {
234+
if (!Py_IS_TYPE(v, Py_TYPE(w)) &&
235+
PyType_IsSubtype(Py_TYPE(w), Py_TYPE(v)) &&
236+
(f = Py_TYPE(w)->tp_richcompare) != NULL) {
241237
checked_reverse_op = 1;
242238
res = (*f)(w, v, _Py_SwappedOp[op]);
243239
if (res != Py_NotImplemented)
244240
return res;
245241
Py_DECREF(res);
246242
}
247-
if ((f = v_type->tp_richcompare) != NULL) {
243+
if ((f = Py_TYPE(v)->tp_richcompare) != NULL) {
248244
res = (*f)(v, w, op);
249245
if (res != Py_NotImplemented)
250246
return res;
251247
Py_DECREF(res);
252248
}
253-
if (!checked_reverse_op && (f = w_type->tp_richcompare) != NULL) {
249+
if (!checked_reverse_op && (f = Py_TYPE(w)->tp_richcompare) != NULL) {
254250
res = (*f)(w, v, _Py_SwappedOp[op]);
255251
if (res != Py_NotImplemented)
256252
return res;
@@ -269,8 +265,8 @@ do_richcompare(PyObject *v, PyObject *w, int op)
269265
PyErr_Format(PyExc_TypeError,
270266
"'%s' not supported between instances of '%.100s' and '%.100s'",
271267
opstrings[op],
272-
v_type->tp_name,
273-
w_type->tp_name);
268+
Py_TYPE(v)->tp_name,
269+
Py_TYPE(w)->tp_name);
274270
return NULL;
275271
}
276272
Py_INCREF(res);

0 commit comments

Comments
 (0)