Type cache can expose previous values during finalization of an object
未关闭
还没有人认领这个 Issue。
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
This should always print True, that is an attribute accessed from a class should match the value that's in the type's mappingproxy:
class X:
def __del__(inner_self):
v = C.a
print(v == C.__dict__['a'])
class C:
a = X()
# prime the cache
C.a
C.a
# destructor shouldn't be able to see inconsisent state
C.a = X()
C.a = X()
But this prints False because the destructor can be run when the assignment into the type dict occurs, but before the type version is invalidated.
CPython versions tested on:
3.8, CPython main branch
Operating systems tested on:
Linux
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在 CPython main 上运行 reproducer,并比较赋值触发的析构函数执行期间的属性查找与类型映射。跟踪类型缓存失效和终结序列;当示例始终输出 True 且不暴露不一致状态时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100