`KeyError` hides the exception raised by str(key)
未关闭
还没有人认领这个 Issue。
interpreter-core
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
>>>a = object.__new__(type(exit))
>>>b = {}
>>>b[a]
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
b[a]
~^^^
KeyError: <exception str() failed>
The exception AttributeError was hidden:
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
b[a]
~^^^
AttributeError: 'Quitter' object has no attribute 'name'
The exception in str() shouldn't be ignore. May because of the lack of the attribute or the wrong type that __str__ return.
CPython versions tested on:
3.13
Operating systems tested on:
Windows
Linked PRs
- gh-139961
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在 CPython 3.13 上重现报告中的 b[a] 示例,并检查 KeyError 消息如何调用 str(key)。查看链接的 PR gh-139961 以了解当前方向;完成的标准是,格式化 key 时引发的 exception 会被保留,而不是被 KeyError 的显示隐藏。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100