From 7108f4deaf1320527b6dcdf45814d12a9f95eaf9 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 14 Mar 2012 21:37:59 -0400 Subject: [PATCH] Oops, Cython uses __richcmp__() instead of __eq__(), etc. http://docs.cython.org/src/userguide/special_methods.html#rich-comparisons --- pycomedi/constant.pyx | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) 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): -- 2.26.2