Behaviour change in defaultdict.__missing__ between 3.13.11 and 3.13.12
未关闭
还没有人认领这个 Issue。
stdlib
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
I have observed a subtle change in behavior of defaultdict.__missing__ between Python 3.13.11 and 3.13.12. Consider the following output:
3.13.11:
$ uv run --python 3.13.11 python -c 'from collections import defaultdict; print(defaultdict(lambda: "A", {None: "B"}).__missing__(None))'
Using CPython 3.13.11
Creating virtual environment at: .venv
Built pdonnx @ file:///Users/christian.bourjau/repos/pdonnx
Installed 1 package in 1ms
A
3.13.12:
$ uv run --python 3.13.12 python -c 'from collections import defaultdict; print(defaultdict(lambda: "A", {None: "B"}).__missing__(None))'
Using CPython 3.13.12
Removed virtual environment at: .venv
Creating virtual environment at: .venv
Installed 1 package in 1ms
B
The same change in behavior can be observed between 3.14.2 and 3.14.3.
This might be related to #142495 and https://github.com/python/cpython/pull/142668
Was this an intentional fix?
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Linked PRs
- gh-148880
- gh-148881
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在 Python 3.13.11、3.13.12、3.14.2 和 3.14.3 上复现报告的 defaultdict.missing(None) 行为,然后阅读 issues #142495 和 pull request #142668 中的上下文。检查关联的 PRs gh-148880 和 gh-148881;当预期行为得到确立,且 issue 有明确的结论或 follow-up 时,工作即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100