summaryrefslogtreecommitdiffstats
path: root/Lib/wave.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-11-16 11:04:00 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-11-16 11:04:00 (GMT)
commit7714ebbe0e7556bbfa6b768e434042b55474939c (patch)
treeedfc3e4daeaca4f88a3efb384c1a34bdf7f808b1 /Lib/wave.py
parenta7a34a83f3f2b9b319cb6f379f6e189066233c76 (diff)
downloadcpython-7714ebbe0e7556bbfa6b768e434042b55474939c.zip
cpython-7714ebbe0e7556bbfa6b768e434042b55474939c.tar.gz
cpython-7714ebbe0e7556bbfa6b768e434042b55474939c.tar.bz2
Issue #5202: Added support for unseekable files in the wave module.
Diffstat (limited to 'Lib/wave.py')
-rw-r--r--Lib/wave.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/wave.py b/Lib/wave.py
index e723423..3d01817 100644
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -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