From: W. Trevor King Date: Thu, 15 Mar 2012 01:46:00 +0000 (-0400) Subject: Fix rich comparison doctest prompts and add comparisons to None. X-Git-Tag: 0.4~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=561a4adef722f63321606385996516fa74cc1c07;p=pycomedi.git Fix rich comparison doctest prompts and add comparisons to None. The None comparison logic avoids: TypeError: long() argument must be a string or a number, not 'NoneType' --- diff --git a/pycomedi/constant.pyx b/pycomedi/constant.pyx index e227f47..1fed075 100644 --- a/pycomedi/constant.pyx +++ b/pycomedi/constant.pyx @@ -88,10 +88,12 @@ False True >>> TRIG_SRC.now != TRIG_SRC.now False -<<< TRIG_SRC.now <= 2 +>>> TRIG_SRC.now <= 2 True -<<< TRIG_SRC.now < 3 +>>> TRIG_SRC.now < 3 False +>>> TRIG_SRC.now > None +True .. [#ops] See `emulating numeric types`_ and `NotImplementedError` in `the standard type hierarchy`_. @@ -171,6 +173,8 @@ cdef class BitwiseOperator (object): return BitwiseOperator(int(long.__or__(s, o))) def __richcmp__(self, other, op): + if other is None: + other = self.value - 1 s,o = BitwiseOperator._prepare_self_other(self, other) if op == 0: return s < o