Improve wave module error messages to include the offending value #149306
Copy link
Copy link
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
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 rateAfter this change:
wave.Error: bad frame rate: -1
I have a patch ready and will open a PR shortly.
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Activity
pythongh-149306: Improve error messages in wave module to include the…
pythongh-149306: Improve error messages in wave module to include the…
Merge remote-tracking branch 'upstream/main' into pythongh-149306-wav…
rhettinger commentedon May 3, 2026
I'm concerned that these LLM created issues are of little value.