python / python/cpython

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

未关闭
#95,710 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

3.10 3.11 3.12 interpreter-core type-bug
主要语言
Python
星标
77.2k
派生
36k
PR 合并指标
PR 指标待抓取

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用类 C 和 D 运行 issue 的 Python 复现程序,检查每个实例的 weakref.ref 行为。跟踪 CPython 对涉及多重继承的实例进行弱引用处理的过程;当 D 实例能够以与其 C 基类一致的方式进行弱引用时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。