]> granicus.if.org Git - python/commitdiff
Fix issue 2245. aifc now skips any chunk type it doesn't actually
authorR. David Murray <rdmurray@bitdance.com>
Wed, 29 Apr 2009 13:17:37 +0000 (13:17 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Wed, 29 Apr 2009 13:17:37 +0000 (13:17 +0000)
process instead of throwing errors for anything not in an explicit
skip list.  This is per this spec: http://www.cnpbagwell.com/aiff-c.txt.
Spec reference and test sound file provided by Santiago Peresón, fix
based on patch by Hiroaki Kawai.

Lib/aifc.py
Lib/test/Sine-1000Hz-300ms.aif [new file with mode: 0644]
Lib/test/test_aifc.py [new file with mode: 0644]
Lib/test/test_sundry.py
Misc/ACKS
Misc/NEWS

index f663dd67d2e7a1f149ab99753097757aff50dc93..8e4f864495d42f90e529f9b6ffcd8a2c0276adb2 100644 (file)
@@ -144,9 +144,6 @@ class Error(Exception):
 
 _AIFC_version = 0xA2805140L     # Version 1 of AIFF-C
 
-_skiplist = 'COMT', 'INST', 'MIDI', 'AESD', \
-      'APPL', 'NAME', 'AUTH', '(c) ', 'ANNO'
-
 def _read_long(file):
     try:
         return struct.unpack('>l', file.read(4))[0]
@@ -314,10 +311,6 @@ class Aifc_read:
                 self._version = _read_ulong(chunk)
             elif chunkname == 'MARK':
                 self._readmark(chunk)
-            elif chunkname in _skiplist:
-                pass
-            else:
-                raise Error, 'unrecognized chunk type '+chunk.chunkname
             chunk.skip()
         if not self._comm_chunk_read or not self._ssnd_chunk:
             raise Error, 'COMM chunk and/or SSND chunk missing'
diff --git a/Lib/test/Sine-1000Hz-300ms.aif b/Lib/test/Sine-1000Hz-300ms.aif
new file mode 100644 (file)
index 0000000..bf08f5c
Binary files /dev/null and b/Lib/test/Sine-1000Hz-300ms.aif differ
diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py
new file mode 100644 (file)
index 0000000..58380e0
--- /dev/null
@@ -0,0 +1,24 @@
+from test.test_support import findfile, run_unittest
+import unittest
+
+import aifc
+
+
+class AIFCTest(unittest.TestCase):
+
+    def setUp(self):
+        self.sndfilepath = findfile('Sine-1000Hz-300ms.aif')
+
+    def test_skipunknown(self):
+        #Issue 2245
+        #This file contains chunk types aifc doesn't recognize.
+        f = aifc.open(self.sndfilepath)
+        f.close()
+
+
+def test_main():
+    run_unittest(AIFCTest)
+
+
+if __name__ == "__main__":
+    unittest.main()
index 48cbcd60f814cc1a1fa5b0b56029618959b5d8f0..cef155bb2aec9940554c0267dc9f952bd05d84da 100644 (file)
@@ -11,7 +11,6 @@ class TestUntestedModules(unittest.TestCase):
         with warnings.catch_warnings():
             warnings.simplefilter("ignore")
             import CGIHTTPServer
-            import aifc
             import audiodev
             import bdb
             import cgitb
index 4b409e1fa2f6b947bfe1c2e96ace90f512f51bea..d650b674c2dc26319948ec2f6e571b1c67f9e1fa 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -370,6 +370,7 @@ Tamito Kajiyama
 Peter van Kampen
 Jacob Kaplan-Moss
 Lou Kates
+Hiroaki Kawai
 Sebastien Keim
 Robert Kern
 Randall Kern
@@ -541,6 +542,7 @@ Randy Pausch
 Samuele Pedroni
 Marcel van der Peijl
 Steven Pemberton
+Santiago Peresón
 Mark Perrego
 Trevor Perrin
 Tim Peters
index efd57d463226326254061da67e2819641613cfa2..7a8cb910803f2f2f4e761fcd7501e88311c9767e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -255,6 +255,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #2245: aifc now skips chunk types it doesn't recognize, per spec.
+
 - Issue #5874: distutils.tests.test_config_cmd is not locale-sensitive 
   anymore.