Traceback Shows Too Much Info For Class Definition Exception
未关闭
还没有人认领这个 Issue。
3.14
interpreter-core
stdlib
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
Given the following:
class Meta(type):
def __prepare__(cls, *args, **kwargs):
raise Exception
class Spam(metaclass=Meta):
a = 1
b = 2
c = 3
d = 4
e = 5
f = 6
I get:
Traceback (most recent call last):
File "<python-input-10>", line 1, in <module>
class Spam(metaclass=Meta):
...<5 lines>...
f = 6
File "<python-input-9>", line 3, in __prepare__
raise Exception
I would expect this to only show the compound statement's "header":
Traceback (most recent call last):
File "<python-input-10>", line 1, in <module>
class Spam(metaclass=Meta):
File "<python-input-9>", line 3, in __prepare__
raise Exception
CC @iritkatriel
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用 issue 中的 class 和 metaclass 示例,在 CPython 的 main 分支上重现 traceback。跟踪解释器如何格式化 class 定义的源代码范围,并查找涵盖复合语句的现有 traceback 测试。完成的标准是:在 prepare 异常之前,traceback 只显示 class 头部。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100