Improve wave module error messages to include the offending value
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the wave module's validation paths, including setframerate(-1), and the Wave_read header parsing mentioned in the issue. Reproduce the current errors, then verify that each relevant message includes the offending value and that the existing wave behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100