summaryrefslogtreecommitdiffstats
path: root/Lib/aifc.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-12-14 18:35:04 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-12-14 18:35:04 (GMT)
commit84d28b4ee5983bcb048323a0e56ea4c5498a0652 (patch)
tree95fdd650d031350b1dc3723764a46a12eb917059 /Lib/aifc.py
parent5da107ac7261d8359cd6e1a9a8e57f85176d1180 (diff)
downloadcpython-84d28b4ee5983bcb048323a0e56ea4c5498a0652.zip
cpython-84d28b4ee5983bcb048323a0e56ea4c5498a0652.tar.gz
cpython-84d28b4ee5983bcb048323a0e56ea4c5498a0652.tar.bz2
Issue #19623: Fixed writing to unseekable files in the aifc module.
Diffstat (limited to 'Lib/aifc.py')
-rw-r--r--Lib/aifc.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py
index 86a5edc..db0924a 100644
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -771,7 +771,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')
@@ -783,7 +786,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)
@@ -794,7 +798,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)