simonpercivall / orderedset

Ordered Set implementation in Cython
Other
74 stars 14 forks source link

Comparing OrderedSet to None throws an error #4

Closed pjrobertson closed 10 years ago

pjrobertson commented 10 years ago

>>> a = OrderedSet([1,2,3]) if some_condition else None
>>> print a
None # a.k.a. a is 'None' in this case
...
>>> # later on...
>>> if a == None:
...       # do something

throws the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/me/.virtualenvs/virtualblah/bin/../lib/python2.7/_abcoll.py", line 186, in __ne__
    return not (self == other)
  File "_orderedset.pyx", line 445, in orderedset._orderedset.OrderedSet.__eq__ (lib/orderedset/_orderedset.c:7554)
TypeError: 'NoneType' object is not iterable

Same if you do a != None but of course the exception is thrown in __ne__ in that case

pjrobertson commented 10 years ago

Cheers :)