Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:
bpo-44782 was opened about the `class LRU(OrderedDict)` in the OrderedDict docs, and its pop() method failing. I think Serhiy's patch here (before revert) may be a good idea (to re-apply). I think it is reasonable to ignore user-implemented dunder methods from subclasses. Concrete type implementations generally do not behave as mix-ins: def never_called(self, *args): print("Never called.") raise ZeroDivisionError class MyList(list): __setitem__ = __delitem__ = __getitem__ = __len__ = __iter__ = __contains__ = never_called class MyDict(dict): __setitem__ = __delitem__ = __getitem__ = __len__ = __iter__ = __contains__ = never_called class MySet(set): __setitem__ = __delitem__ = __getitem__ = __len__ = __iter__ = __contains__ = never_called L = MyList([5, 4, 3, 2]) L.sort() L.pop(1) L.insert(0, 42) L.pop() L.reverse() assert type(L) is MyList D = MyDict({"a": 1, "b": 2, "c": 3}) assert D.get(0) is None assert D.get("a") == 1 assert D.pop("b") == 2 assert D.popitem() == ("c", 3) assert type(D) is MyDict S = MySet({"a", "b", "c"}) S.discard("a") S.remove("b") S.isdisjoint(S) S |= S S &= S S ^= S assert type(S) is MySet ---------- nosy: +Dennis Sweeney _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue27275> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com