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.

Title: aifc cannot handle unrecognised chunk type "CHAN"
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: kawai, loki_dePlume, r.david.murray, sjoerd, yaco
Priority: normal Keywords: easy

Created on 2008-03-06 16:52 by loki_dePlume, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit yaco, 2009-04-28 11:56 zip-compressed aiff file with an FLLR chunk
Messages (9)
msg63326 - (view) Author: Oki Mikito (loki_dePlume) Date: 2008-03-06 16:52
When aifc tries to open an AIFF audio file, it collects the file's chunk 
information. Apparently some AIFF files contain a chunk type string "CHAN", 
and the module just won't open the files...

Here's a captured error message:
>>> import os
>>> os.getcwd()
'C:¥¥Documents and Settings¥¥loki'
>>> import aifc
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:¥Python25¥lib¥", line 928, in open
    return Aifc_read(f)
  File "C:¥Python25¥lib¥", line 341, in __init__
  File "C:¥Python25¥lib¥", line 320, in initfp
    raise Error, 'unrecognized chunk type '+chunk.chunkname
Error: unrecognized chunk type CHAN

Solution: Add 'CHAN' in the list of _skiplist item, in lib/, line 147
msg63480 - (view) Author: HiroakiKawai (kawai) Date: 2008-03-12 17:11
Issue2259 patches will also fix this issue. :-)
msg84064 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-03-24 08:45
The patch posted in issue 2259 solves this issue by deleting the
skiplist entirely and simply ignoring any unknown chunk.  Given the
relatively long list of skipped types compared to the short list of
handled types, this may be reasonable.

I am recommending in that issue that the skiplist change be broken out
into a separate patch and attached to this ticket as a proposed fix.

An alternative fix would be to add CHAN to the skiplist and/or turn the
existing error into a warning.  Someone more knowledgeable about AIFF
and sound files would perhaps know which would be more appropriate.
msg84071 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2009-03-24 09:58
I wrote the module 16 years ago, but haven't done anything with AIFF
files for probably at least 10, so I can't really comment on the merits
of the two solutions (delete _skiplist or add CHAN to _skiplist).  I'm
fine with either.
However, the proposed patch leaves an `else: pass' which should be
removed if the patch is adopted.
msg86578 - (view) Author: Santiago Peresón (yaco) Date: 2009-04-26 00:41
according to the spec at [1]:

"Dealing with Unrecognized Local Chunks

When reading an IFF file, your program may encounter local chunk types
that it doesn't recognize, perhaps extensions defined after your
program was written. [...]  Clearly your
program cannot process the contents of unrecognized chunks.  So what
should your program do when it encounters unrecognized chunks in an
IFF FORM?  The safest thing is to simply discard them while reading
the FORM.  If your program copies the FORM without edits, then it 's
nicer [but not necessary] to copy unrecognized chunks, too.  But if
your program modifies the data in any way, then it must discard all
unrecognized chunks.  That's because it can't possibly update the
unrecognized data to be consistent with the modifications."

ie: unrecognized chunks should be just skipped when reading, and not
copied if the file is modified, so both deleting the _skiplist or
applying the patch posted in issue 2259 would fix this bug according to

a limited workaround for known format files is to append the offending
chunk IDs to the _skiplist before reading, ie:

>>> import aifc
>>> f ='test.aiff')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/sw/lib/python2.6/", line 929, in open
    return Aifc_read(f)
  File "/sw/lib/python2.6/", line 341, in __init__
  File "/sw/lib/python2.6/", line 320, in initfp
    raise Error, 'unrecognized chunk type '+chunk.chunkname
aifc.Error: unrecognized chunk type FLLR
>>> aifc._skiplist += ('FLLR',)
>>> f ='test.aiff')
>>> f
<aifc.Aifc_read instance at 0x76f80>

(Apple's Sountrack Pro adds an 'FLLR' padding chunk to AIFF files, so
_every_ file created by it will fail in the same way).
msg86579 - (view) Author: Santiago Peresón (yaco) Date: 2009-04-26 00:43
[1] couldn't find the spec at, but the linked one
seems to be a copy of the original 1991 spec.
msg86633 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-04-27 00:42
If someone can supply a small sample audio file that will trigger the
failure(s) in the existing code, I will write the tests and commit the
issue2259 patch.
msg86729 - (view) Author: Santiago Peresón (yaco) Date: 2009-04-28 11:56
the attached file triggers the bug.
msg86800 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-04-29 13:20
Fixed in r72100.  Thanks everyone.  Now for issue 2259...
Date User Action Args
2022-04-11 14:56:31adminsetgithub: 46498
2009-04-29 13:20:01r.david.murraysetstatus: open -> closed
resolution: fixed
messages: + msg86800

stage: test needed -> resolved
2009-04-28 11:56:19yacosetfiles: +

messages: + msg86729
2009-04-27 00:42:56r.david.murraysetassignee: r.david.murray
messages: + msg86633
2009-04-26 00:43:10yacosetmessages: + msg86579
2009-04-26 00:41:32yacosetnosy: + yaco
messages: + msg86578
2009-03-24 09:58:08sjoerdsetmessages: + msg84071
2009-03-24 08:45:17r.david.murraysetpriority: normal

type: enhancement -> behavior
versions: + Python 2.6, Python 3.0, Python 3.1, Python 2.7, - Python 2.5
keywords: + easy
nosy: + r.david.murray

messages: + msg84064
stage: test needed
2008-03-12 17:11:40kawaisetnosy: + kawai
messages: + msg63480
2008-03-06 23:07:52benjamin.petersonsetnosy: + sjoerd
2008-03-06 16:52:23loki_dePlumecreate