Author Dennis Sweeney
Recipients Dennis Sweeney, eric.snow, josh.r, kaniini, methane, python-dev, rhettinger, serhiy.storchaka, xiang.zhang, zach.ware
Date 2021-07-31.05:47:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627710479.09.0.858796802316.issue27275@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-07-31 05:47:59Dennis Sweeneysetrecipients: + Dennis Sweeney, rhettinger, methane, python-dev, eric.snow, zach.ware, serhiy.storchaka, josh.r, xiang.zhang, kaniini
2021-07-31 05:47:59Dennis Sweeneysetmessageid: <1627710479.09.0.858796802316.issue27275@roundup.psfhosted.org>
2021-07-31 05:47:59Dennis Sweeneylinkissue27275 messages
2021-07-31 05:47:58Dennis Sweeneycreate