mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
Issue #5202: Added support for unseekable files in the wave module.
This commit is contained in:
parent
a7a34a83f3
commit
7714ebbe0e
5 changed files with 90 additions and 34 deletions
|
@ -491,14 +491,18 @@ class Wave_write:
|
|||
if not self._nframes:
|
||||
self._nframes = initlength // (self._nchannels * self._sampwidth)
|
||||
self._datalength = self._nframes * self._nchannels * self._sampwidth
|
||||
self._form_length_pos = self._file.tell()
|
||||
try:
|
||||
self._form_length_pos = self._file.tell()
|
||||
except (AttributeError, OSError):
|
||||
self._form_length_pos = None
|
||||
self._file.write(struct.pack('<L4s4sLHHLLHH4s',
|
||||
36 + self._datalength, b'WAVE', b'fmt ', 16,
|
||||
WAVE_FORMAT_PCM, self._nchannels, self._framerate,
|
||||
self._nchannels * self._framerate * self._sampwidth,
|
||||
self._nchannels * self._sampwidth,
|
||||
self._sampwidth * 8, b'data'))
|
||||
self._data_length_pos = self._file.tell()
|
||||
if self._form_length_pos is not None:
|
||||
self._data_length_pos = self._file.tell()
|
||||
self._file.write(struct.pack('<L', self._datalength))
|
||||
self._headerwritten = True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue