Ability to weakly reference an instance of a class lost due to mutliple inheritance
Open
Nobody has claimed this yet.
3.10
3.11
3.12
interpreter-core
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
This is related to https://github.com/python/cpython/issues/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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the issue's Python reproducer with classes C and D, checking the weakref.ref behavior for each instance. Trace the CPython weak-reference handling for instances involving multiple inheritance; done means a D instance can be weakly referenced consistently with its C base.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100