Fix python comparison operators throwing exceptions

* When used in richcompare this would throw an exception and return
  Py_NotImplemented causing a failure. Instead we should just return NULL, which
  is fine and will be considered as a not-equal comparison for
  equality/inequality and throw the kind of exception we want for less than or
  greater than.
This commit is contained in:
baldurk
2022-12-13 11:12:45 +00:00
parent b3ae354645
commit eab6a2c73c
+3 -3
View File
@@ -22,7 +22,7 @@ PyObject *__lt__(PyObject *other)
{
int res = SWIG_ConvertPtr(other, &resptr, SWIGTYPE_p_ResourceId, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "incorrect comparison type");
goto fail;
}
id = (ResourceId *)resptr;
@@ -129,7 +129,7 @@ PyObject *__eq__(PyObject *other)
{
int res = SWIG_ConvertPtr(other, &resptr, SWIGTYPE_p_##Class, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "incorrect comparison type");
goto fail;
}
id = (Class *)resptr;
@@ -152,7 +152,7 @@ PyObject *__ne__(PyObject *other)
{
int res = SWIG_ConvertPtr(other, &resptr, SWIGTYPE_p_##Class, 0);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "incorrect comparison type");
goto fail;
}
id = (Class *)resptr;