This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Support for writing aifc to unseekable file
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: python-dev, r.david.murray, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-11-16 11:44 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
aifc_write_unseekable.patch serhiy.storchaka, 2013-11-16 11:44 review
Messages (3)
msg203026 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-16 11:44
The aifc module documentation mentions that underlying file can be unseekable if the number of frames are specified.

   When
   used for writing, the file object should be seekable, unless you know ahead of
   time how many samples you are going to write in total and use
   :meth:`writeframesraw` and :meth:`setnframes`.

But this doesn't work.

>>> import aifc
>>> f = aifc.open('/dev/stdout', 'w')
>>> f.setnchannels(1)
>>> f.setsampwidth(1)
>>> f.setframerate(8000)
>>> f.setcomptype(b'NONE', b'not compressed')
>>> f.setnframes(1)
>>> f.writeframesraw(b'\0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/aifc.py", line 695, in writeframesraw
    self._ensure_header_written(len(data))
  File "/home/serhiy/py/cpython/Lib/aifc.py", line 763, in _ensure_header_written
    self._write_header(datasize)
  File "/home/serhiy/py/cpython/Lib/aifc.py", line 791, in _write_header
    self._form_length_pos = self._file.tell()
OSError: [Errno 29] Illegal seek

Here is a patch which makes the code to conform with the documentation.
msg206197 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-12-14 18:43
New changeset c10ea224392d by Serhiy Storchaka in branch '2.7':
Issue #19623: Fixed writing to unseekable files in the aifc module.
http://hg.python.org/cpython/rev/c10ea224392d

New changeset 35f6a5937a63 by Serhiy Storchaka in branch '3.3':
Issue #19623: Fixed writing to unseekable files in the aifc module.
http://hg.python.org/cpython/rev/35f6a5937a63

New changeset 804406d79b45 by Serhiy Storchaka in branch 'default':
Issue #19623: Fixed writing to unseekable files in the aifc module.
http://hg.python.org/cpython/rev/804406d79b45
msg206198 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-12-14 18:45
During applying the patch to 2.7 yet one bug was found in 2.7.
History
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63822
2013-12-14 18:45:06serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg206198

stage: patch review -> resolved
2013-12-14 18:43:23python-devsetnosy: + python-dev
messages: + msg206197
2013-12-12 20:28:41serhiy.storchakasetassignee: serhiy.storchaka
2013-11-16 11:44:40serhiy.storchakacreate