diff options
author | Georg Brandl <georg@python.org> | 2010-10-30 08:29:28 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-10-30 08:29:28 (GMT) |
commit | cc2adbc693c669bb212ea90483600eb3d71349c3 (patch) | |
tree | 7e7707be54d8663579da40bc2e120f4ed0484a31 | |
parent | dd4215483f369f17e15804179212493c76b7bc41 (diff) | |
download | cpython-cc2adbc693c669bb212ea90483600eb3d71349c3.zip cpython-cc2adbc693c669bb212ea90483600eb3d71349c3.tar.gz cpython-cc2adbc693c669bb212ea90483600eb3d71349c3.tar.bz2 |
#10198: fix duplicate header when writeframes() is called with an empty string.
-rw-r--r-- | Lib/wave.py | 6 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/Lib/wave.py b/Lib/wave.py index 57f9d17..b5bb105 100644 --- a/Lib/wave.py +++ b/Lib/wave.py @@ -319,6 +319,7 @@ class Wave_write: self._nframeswritten = 0 self._datawritten = 0 self._datalength = 0 + self._headerwritten = False def __del__(self): self.close() @@ -449,7 +450,7 @@ class Wave_write: # def _ensure_header_written(self, datasize): - if not self._datawritten: + if not self._headerwritten: if not self._nchannels: raise Error('# channels not specified') if not self._sampwidth: @@ -459,6 +460,7 @@ class Wave_write: self._write_header(datasize) def _write_header(self, initlength): + assert not self._headerwritten self._file.write(b'RIFF') if not self._nframes: self._nframes = initlength // (self._nchannels * self._sampwidth) @@ -472,8 +474,10 @@ class Wave_write: self._sampwidth * 8, 'data')) self._data_length_pos = self._file.tell() self._file.write(struct.pack('<l', self._datalength)) + self._headerwritten = True def _patchheader(self): + assert self._headerwritten if self._datawritten == self._datalength: return curpos = self._file.tell() @@ -57,6 +57,9 @@ Core and Builtins Library ------- +- Issue #10198: fix duplicate header written to wave files when writeframes() + is called without data. + - Close file objects in modulefinder in a timely manner. - Close a io.TextIOWrapper object in email.parser in a timely manner. |