DanielStutzbach / blist

A list-like type with better asymptotic performance and similar performance on small lists
Other
313 stars 35 forks source link

btuple raises TypeError instead of returning NotImplemented #37

Closed ozomer closed 11 years ago

ozomer commented 12 years ago

I want to add some functionality using radd .

class MyClass(object):
    def __radd__(self, other):
        return 7

If I create a new MyClass object and get:

>>> c = Coo()
>>> () + Coo()
7
>>> [] + Coo()
7
>>> blist.blist() + Coo()
7
>>> blist.btuple() + Coo()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/blist-1.3.4-py2.6-linux-i686.egg/_btuple.py", line 47, in __add__
    raise TypeError
TypeError

This happens because the add function returns raises TypeError instead of returning NotImplemeted, so the other object's radd is not called.