tarfile.TarFile.next() adds an unnecessary traceback frame when reraising exceptions
未关闭
还没有人认领这个 Issue。
stdlib
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
description:
https://gist.github.com/devdanzin/f8af359770ff200eac8474de5644be82
tarfile.TarFile.next() currently reraises non-zlib exceptions with raise e
inside its generic exception handler:
except Exception as e:
try:
import zlib
if isinstance(e, zlib.error):
raise ReadError(f'zlib error: {e}') from None
else:
raise e
except ImportError:
raise e
Using raise e adds an extra traceback frame at the re-raise site. A bare
raise would keep the traceback cleaner while preserving the original exception
and its traceback.
CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Windows
Linked PRs
- gh-149761
- gh-157257
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在 tarfile 模块中搜索 TarFile.next(),并检查 issue 中显示的通用异常处理器。确认链接的 gist 中描述的 traceback 差异,然后在完成异常处理更改后运行 tarfile 测试,以验证非 zlib 异常保留其原始 traceback,且 zlib 错误保持不变。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100