]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
python: Fix rich comparison for AS objects
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 21 Feb 2024 16:04:24 +0000 (16:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 21 Feb 2024 16:04:24 +0000 (16:04 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/as.c

index 06ba5db305eba4f0f2ea795f2dd9cb31fc921c8d..2f4b26f65b9981c4c0bcd340dce76da83ed2cd65 100644 (file)
@@ -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: