From: Michael Tremer Date: Wed, 21 Feb 2024 16:04:24 +0000 (+0000) Subject: python: Fix rich comparison for AS objects X-Git-Tag: 0.9.18~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c2e4346af93bdbf2c77242dc7e178e97ab55d59;p=location%2Flibloc.git python: Fix rich comparison for AS objects Signed-off-by: Michael Tremer --- diff --git a/src/python/as.c b/src/python/as.c index 06ba5db..2f4b26f 100644 --- a/src/python/as.c +++ b/src/python/as.c @@ -102,8 +102,16 @@ static int AS_set_name(ASObject* self, PyObject* value) { return 0; } -static PyObject* AS_richcompare(ASObject* self, ASObject* other, int op) { - int r = loc_as_cmp(self->as, other->as); +static PyObject* AS_richcompare(ASObject* self, PyObject* other, int op) { + int r; + + // Check for type + if (!PyObject_IsInstance(other, (PyObject *)&ASType)) + Py_RETURN_NOTIMPLEMENTED; + + ASObject* o = (ASObject*)other; + + r = loc_as_cmp(self->as, o->as); switch (op) { case Py_EQ: