When my lowercase names collide (e.g. for COMEDI_TO_PHYSICAL and
comedi_to_physical), we want to add the integer value to the enum, not
the function value. This avoids:
>>> from pycomedi.device import Device
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "instruction.pxd", line 22, in init pycomedi.device (pycomedi/device.c:4532)
File "instruction.pyx", line 25, in init pycomedi.instruction (pycomedi/instruction.c:2427)
File "chanspec.pyx", line 20, in init pycomedi.chanspec (pycomedi/chanspec.c:2571)
File "constant.pyx", line 469, in init pycomedi.constant (pycomedi/constant.c:10017)
File "constant.pyx", line 244, in pycomedi.constant._Enum.__init__ (pycomedi/constant.c:3804)
File "constant.pyx", line 260, in pycomedi.constant._Enum._add_item (pycomedi/constant.c:4305)
TypeError: unorderable types: builtin_function_or_method() < int()
I'm not sure how I haven't bumped into this before. Perhaps Cython
0.19.1 has stronger type-checking for its comparison operaters than my
old 0.17.4.
def _add_item(self, attr, item_name):
item_value = getattr(_comedi, attr)
+ if not isinstance(item_value, int):
+ return # item_name collided with another object, skip this non-int
if item_value < 0:
_LOG.debug('big value for {0:s}: {1:d} ({1:b}) converted to {2:d} ({2:b})'.format(
attr, item_value, (1<<32) + item_value))