More programmatic access to error locations in the traceback module
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 558
描述
Feature or enhancement
I'd like for the traceback module to have a more programmatic way to access the fine-grained error locations that are printed in tracebacks starting in Python 3.11 (PEP 657).
Pitch
The new fine-grained error information in tracebacks is nice. But I'd like to be able to write a custom traceback printer that uses this information and prints it in a different way (I'd like to highlight the characters in the lines of source rather than having ASCII characters under them).
The logic for getting the locations of the printed fine-grained information is present in the traceback module, but unfortunately, it's only present inside of the format_frame_summary() method, which returns a string. That means that to access the information, I have to parse the string.
It would be convenient if the logic in that method were separated out into a separate method that returned the column numbers, so that it could be called from a superclass. I would be fine if this method is private, so that it wouldn't strictly speaking add a new API or hard-code the existing traceback information into the API.
Previous discussion
I haven't followed the discussions on PEP 657 so I don't know if this has been discussed previously. I don't see any mention of the traceback module in the PEP.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Lib/traceback.py 中的 format_frame_summary() 开始,这里描述了现有的细粒度 traceback 位置逻辑。确定如何分离该逻辑,以便在不解析返回字符串的情况下,为自定义 traceback 格式化提供列号。完成的标准是调用方可以通过程序访问这些位置,同时保留现有的 traceback 输出。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100