Skip to content

Ability to weakly reference an instance of a class lost due to mutliple inheritance #95710

Open
@markshannon

Description

@markshannon

This is related to #95589 due to underlying mechanism, but the behavior is distinct.

class C: 
    pass

class D(int, C):
    pass
>>> c = C()
>>> weakref.ref(c)
<weakref at 0x7fa5b2af9c60; to 'C' at 0x7fa5b2e501c0>
>>> d = D()
>>> weakref.ref(d)
TypeError: cannot create weak reference to 'D' object
>>> isinstance(d, C)
True

If I can weakly reference an instance of C, then I should be able to weakly reference an instance of D. Instances of D are instances of C

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.11only security fixes3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions