From: W. Trevor King Date: Thu, 15 Mar 2012 01:37:59 +0000 (-0400) Subject: Oops, Cython uses __richcmp__() instead of __eq__(), etc. X-Git-Tag: 0.4~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7108f4deaf1320527b6dcdf45814d12a9f95eaf9;p=pycomedi.git Oops, Cython uses __richcmp__() instead of __eq__(), etc. http://docs.cython.org/src/userguide/special_methods.html#rich-comparisons --- diff --git a/pycomedi/constant.pyx b/pycomedi/constant.pyx index 0edf64b..e227f47 100644 --- a/pycomedi/constant.pyx +++ b/pycomedi/constant.pyx @@ -170,29 +170,22 @@ cdef class BitwiseOperator (object): s,o = BitwiseOperator._prepare_self_other(self, other) return BitwiseOperator(int(long.__or__(s, o))) - def __lt__(self, other): + def __richcmp__(self, other, op): s,o = BitwiseOperator._prepare_self_other(self, other) - return s < o - - def __le__(self, other): - s,o = BitwiseOperator._prepare_self_other(self, other) - return s <= o - - def __eq__(self, other): - s,o = BitwiseOperator._prepare_self_other(self, other) - return s == o - - def __ne__(self, other): - s,o = BitwiseOperator._prepare_self_other(self, other) - return s != o - - def __gt__(self, other): - s,o = BitwiseOperator._prepare_self_other(self, other) - return s > o - - def __ge__(self, other): - s,o = BitwiseOperator._prepare_self_other(self, other) - return s >= o + if op == 0: + return s < o + elif op == 1: + return s <= o + elif op == 2: + return s == o + elif op == 3: + return s != o + elif op == 4: + return s > o + elif op == 5: + return s >= o + else: + raise ValueError(op) class _NamedInt (BitwiseOperator):