Bug description
wave.open(f, 'rb') is documented to raise wave.Error when a file violates
the WAV format, but it leaks a raw EOFError when the fmt chunk is truncated
(the chunk header declares 16 bytes but fewer are present):
>>> import io, struct, wave
>>> b = b'RIFF' + struct.pack('<L', 24) + b'WAVE' + b'fmt ' + struct.pack('<L', 16) + struct.pack('<HHLLH', 1, 1, 11025, 11025, 1)
>>> wave.open(io.BytesIO(b))
Traceback (most recent call last):
...
EOFError
Expected: wave.Error. Wave_read._read_fmt_chunk() raises EOFError on a
short read, but Wave_read.initfp() does not wrap that call, so it escapes the
public API. Every other malformed-input path in the module raises wave.Error.
CPython versions tested on
3.13, 3.14, 3.15
Operating systems tested on
Linux, macOS
Linked PRs
Bug description
wave.open(f, 'rb')is documented to raisewave.Errorwhen a file violatesthe WAV format, but it leaks a raw
EOFErrorwhen thefmtchunk is truncated(the chunk header declares 16 bytes but fewer are present):
Expected:
wave.Error.Wave_read._read_fmt_chunk()raisesEOFErroron ashort read, but
Wave_read.initfp()does not wrap that call, so it escapes thepublic API. Every other malformed-input path in the module raises
wave.Error.CPython versions tested on
3.13, 3.14, 3.15
Operating systems tested on
Linux, macOS
Linked PRs