Regression: 3.13 `traceback.format_list()` breaking behavior change.
未关闭
还没有人认领这个 Issue。
docs
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
traceback.format_list() no longer works with lines that have breaks in them:
import traceback
import sys
print(f"Python {sys.version_info.major}.{sys.version_info.minor}")
# Frame with multiline text (source + variable annotations)
frames = [('test.py', 10, 'func', 'x = foo + bar\n\t\thello\n\tworld')]
print("\nInput (3 lines):")
print(repr(frames[0][3]))
print("\nOutput from traceback.format_list():")
result = traceback.format_list(frames)[0] # Yes, it't always a 1-element list both on 3.12 adn 3.13.
print(result)
Python 3.12
Input (3 lines):
'x = foo + bar\n\t\thello\n\tworld'
Output from traceback.format_list():
File "test.py", line 10, in func
x = foo + bar
hello
world
Python 3.13
Input (3 lines):
'x = foo + bar\n\t\thello\n\tworld'
Output from traceback.format_list():
File "test.py", line 10, in func
x = foo + bar
This broke bettre_exceptions on 3.13, which was fixed by formatting the traceback manually. Can we either
- Revert to old behavior in 3.15 and maybe document that it was broken in 3.13 and 3.14?
- Document the behavior change?
ref: https://github.com/Qix-/better-exceptions/issues/134
CPython versions tested on:
3.13
Operating systems tested on:
No response
Linked PRs
- gh-153469
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 Python 3.12 和 3.13 复现提供的脚本,然后从 traceback.format_list() 开始。先检查已链接的 PR gh-153469 以及 traceback 周围的行为,再决定目标是兼容性还是文档。完成的标准是:已接受的行为得到实现或记录,并且多行情况由相关测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100