From 25b4add5b0569e626afd8b3b5b7dd4a7551372c9 Mon Sep 17 00:00:00 2001 From: "R. David Murray" Date: Wed, 29 Apr 2009 13:17:37 +0000 Subject: [PATCH] =?utf8?q?Fix=20issue=202245.=20=20aifc=20now=20skips=20an?= =?utf8?q?y=20chunk=20type=20it=20doesn't=20actually=20process=20instead?= =?utf8?q?=20of=20throwing=20errors=20for=20anything=20not=20in=20an=20exp?= =?utf8?q?licit=20skip=20list.=20=20This=20is=20per=20this=20spec:=20http:?= =?utf8?q?//www.cnpbagwell.com/aiff-c.txt.=20Spec=20reference=20and=20test?= =?utf8?q?=20sound=20file=20provided=20by=20Santiago=20Peres=C3=B3n,=20fix?= =?utf8?q?=20based=20on=20patch=20by=20Hiroaki=20Kawai.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Lib/aifc.py | 7 ------- Lib/test/Sine-1000Hz-300ms.aif | Bin 0 -> 61696 bytes Lib/test/test_aifc.py | 24 ++++++++++++++++++++++++ Lib/test/test_sundry.py | 1 - Misc/ACKS | 2 ++ Misc/NEWS | 2 ++ 6 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 Lib/test/Sine-1000Hz-300ms.aif create mode 100644 Lib/test/test_aifc.py diff --git a/Lib/aifc.py b/Lib/aifc.py index f663dd67d2..8e4f864495 100644 --- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -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 index 0000000000000000000000000000000000000000..bf08f5ce859429eeeab213fd29a201b0d851b9c3 GIT binary patch literal 61696 zcmeI&F-t;G6ae5$QxH_-;Ns*IlCzCQp$4VU8$`!`gF`emiG#nv&1lHMO=u9Bnj^xc zA!uj`8XOw)(9%Ds;dAhL-@EtvIOu!tp7YgOXQwHBejOawYKN`U)#tR6)>7K9rtRwH z-PNkSdeu%&&QjXC|7m#_0TB=Z5fA|p5CIVo0TB=Z5fA|p_}>x8vgT1ruj{|ha^q>^ zDc{TYij(4`+$y&!rAn!qtLEx&^|$6_^D>)dv-Y4p=qx&m?x;J8ZM0*59FKm{KgPxQ zm?!3odEahkL#!Vm;0~h2hVSwKRrKNzgT}+KU%-b zKggfRU&+78AIjg#Kg*x1U#P#RAF1D|KdPUqU#q|K1N;C#zz^^P`~W||5AXy006)MF z@B{n+Kfn+01N;C#zz^^P`~W||5AXy006)MF@B{n+Kfn+01N;C#zz^^P`~W||5AXy0 z06)MF@B{n+Kfn+01N;C#zz^^P`~W||5AXy006)MF@B{n+Kfn+01N;C#zz^^P`~W|| z5AXy006)MF@B{n+Kfn+01N;C#zz^^P`~W||5AXy006)MF@B{n+Kfn+01N;C#zz^^P z`~W||5AXy006)MF@B{n+Kfn+01N;C#zz^^P`~W||5AXy006)MF@B{n+Kfn+01N;C# zzz^^P`~W||5AXy006)MF@B{n+Kfn+01N;C#zz^^P`~W||5AXy006)MF@B{n+Kfn+0 z1N;C#zz^^P`~W||5AXy006)MF@B{n+Kfn+01N;C#zz^^P`~W||5AXy006)MF@B{q7 HU;BY?t&pq( literal 0 HcmV?d00001 diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py new file mode 100644 index 0000000000..58380e0e9d --- /dev/null +++ b/Lib/test/test_aifc.py @@ -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() diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py index 48cbcd60f8..cef155bb2a 100644 --- a/Lib/test/test_sundry.py +++ b/Lib/test/test_sundry.py @@ -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 diff --git a/Misc/ACKS b/Misc/ACKS index 4b409e1fa2..d650b674c2 100644 --- 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 diff --git a/Misc/NEWS b/Misc/NEWS index efd57d4632..7a8cb91080 100644 --- 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. -- 2.50.1