diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-12-14 18:42:22 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-12-14 18:42:22 (GMT) |
commit | 79f19f9e7c1849be68bba57ee78c116714e2c5ea (patch) | |
tree | b94507a79a0fbd36d29ee7f28d0a3d63e2d56b7f /Lib/aifc.py | |
parent | 03241e801780edd967923d1cce00c2d07b208e58 (diff) | |
parent | 84d28b4ee5983bcb048323a0e56ea4c5498a0652 (diff) | |
download | cpython-79f19f9e7c1849be68bba57ee78c116714e2c5ea.zip cpython-79f19f9e7c1849be68bba57ee78c116714e2c5ea.tar.gz cpython-79f19f9e7c1849be68bba57ee78c116714e2c5ea.tar.bz2 |
Issue #19623: Fixed writing to unseekable files in the aifc module.
Diffstat (limited to 'Lib/aifc.py')
-rw-r--r-- | Lib/aifc.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py index c1c8ea7..9e64de9 100644 --- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -790,7 +790,10 @@ class Aifc_write: self._datalength = (self._datalength + 3) // 4 if self._datalength & 1: self._datalength = self._datalength + 1 - self._form_length_pos = self._file.tell() + try: + self._form_length_pos = self._file.tell() + except (AttributeError, OSError): + self._form_length_pos = None commlength = self._write_form_length(self._datalength) if self._aifc: self._file.write(b'AIFC') @@ -802,7 +805,8 @@ class Aifc_write: self._file.write(b'COMM') _write_ulong(self._file, commlength) _write_short(self._file, self._nchannels) - self._nframes_pos = self._file.tell() + if self._form_length_pos is not None: + self._nframes_pos = self._file.tell() _write_ulong(self._file, self._nframes) if self._comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'): _write_short(self._file, 8) @@ -813,7 +817,8 @@ class Aifc_write: self._file.write(self._comptype) _write_string(self._file, self._compname) self._file.write(b'SSND') - self._ssnd_length_pos = self._file.tell() + if self._form_length_pos is not None: + self._ssnd_length_pos = self._file.tell() _write_ulong(self._file, self._datalength + 8) _write_ulong(self._file, 0) _write_ulong(self._file, 0) |