You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The WithEq class has default comparison: it doesn't define any sorting methods.
The C implementation doesn't detect this (because just defining __eq__ is enough to fill in the tp_richcompare slot):
$ python /tmp/foo.py
$
The Python implementation does detect this:
$ PURE_PYTHON=1 python /tmp/foo.pyTraceback (most recent call last): File "/tmp/foo.py", line 7, in <module> s.add(WithEq()) File "//BTrees/src/BTrees/_base.py", line 1406, in add return self._set(self._to_key(key))[0] File "//BTrees/src/BTrees/_datatypes.py", line 255, in __call__ raise TypeError("Object of class %s has default comparison" % (type(item).__name__,))TypeError: Object of class WithEq has default comparison
Consider:
The
WithEq
class has default comparison: it doesn't define any sorting methods.The C implementation doesn't detect this (because just defining
__eq__
is enough to fill in thetp_richcompare
slot):$ python /tmp/foo.py $
The Python implementation does detect this:
Can we improve the C implementation?
BTrees/src/BTrees/objectkeymacros.h
Lines 23 to 33 in 86fd464
A real-world class that demonstrates this is
persistent.wref.WeakRef
.The text was updated successfully, but these errors were encountered: