[Python-bugs-list] [Bug #116271] corrupted wave file header

noreply@sourceforge.net noreply@sourceforge.net
Mon, 9 Oct 2000 17:48:13 -0700


Bug #116271, was updated on 2000-Oct-06 13:05
Here is a current snapshot of the bug.

Project: Python
Category: Library
Status: Closed
Resolution: Fixed
Bug Group: None
Priority: 5
Summary: corrupted wave file header

Details: In module wave.py at line 442 (python2.0b2)
in method _write_header of Wave_write class
the format argument of struct.pack is incorrect:

it should be '<l4s4slhhllhh4s'
(sizes for strings were missing)

by the way, there is no test_wave.py.

here is a simple one:

import os, tempfile
import wave

nchannels = 2
sampwidth = 2
framerate = 8000
nframes = 100

testfile = tempfile.mktemp()

f = wave.open(testfile, 'w')
f.setnchannels(nchannels)
f.setsampwidth(sampwidth)
f.setframerate(framerate)
f.setnframes(nframes)
output = '\0' * nframes * nchannels * sampwidth
f.writeframes(output)
f.close()

f = wave.open(testfile, 'r')
assert nchannels == f.getnchannels()
assert sampwidth == f.getsampwidth()
assert framerate == f.getframerate()
assert nframes == f.getnframes()
input = f.readframes(nframes)
assert input == output
f.close()

os.remove(testfile)

Follow-Ups:

Date: 2000-Oct-09 17:48
By: gvanrossum

Comment:
Checked in (bug and test script) and closed. Thanks!

Your test script caused  a little last-minute scare: it broke on Windows. We discovered that the wave module never closes files even when it opened them. Serves us right for never testing it! Fixed now.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=116271&group_id=5470