Improve wave module error messages to include the offending value
未关闭
还没有人认领这个 Issue。
stdlib
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Summary
The wave module currently raises errors without the offending value:
wave.Error: bad # of channels
wave.Error: bad sample width
wave.Error: bad frame rate
When values come from variables, configuration, or parsed data, the
traceback shows the call site but not the actual offending value. For
Wave_read, the values are parsed from the WAV file header and never
appear in the traceback at all.
Reproduction
import wave, io
wave.open(io.BytesIO(), 'wb').setframerate(-1)
# wave.Error: bad frame rate
After this change:
wave.Error: bad frame rate: -1
I have a patch ready and will open a PR shortly.
Linked PRs
- gh-149307
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 wave 模块的验证路径开始,包括 setframerate(-1),以及 issue 中提到的 Wave_read 头部解析。重现当前错误,然后验证每条相关消息都包含引发错误的值,并确认 wave 的现有行为保持不变。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- audio-video-rtc
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100