diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-02-20 22:17:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-20 22:17:30 (GMT) |
commit | 2b9726eb647e856d83eafdc30cdbbc31a5920ab6 (patch) | |
tree | dae79987334c78d111eb1b5f14daf03095bcc387 /Lib/test/test_aifc.py | |
parent | 6ae87cae091f4835090c10c1e65eb057a13fca2c (diff) | |
download | cpython-2b9726eb647e856d83eafdc30cdbbc31a5920ab6.zip cpython-2b9726eb647e856d83eafdc30cdbbc31a5920ab6.tar.gz cpython-2b9726eb647e856d83eafdc30cdbbc31a5920ab6.tar.bz2 |
bpo-31848: Fix broken error handling in Aifc_read.initfp() when the SSND chunk is not found (GH-5240)
Initialize self._ssnd_chunk so that aifc.Error is raised as intended,
not AttributeError.
(cherry picked from commit 80d20b918bd8a882043c493a7f958333ecb41727)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Lib/test/test_aifc.py')
-rw-r--r-- | Lib/test/test_aifc.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py index a731a51..9e8cd17 100644 --- a/Lib/test/test_aifc.py +++ b/Lib/test/test_aifc.py @@ -263,6 +263,14 @@ class AIFCLowLevelTest(unittest.TestCase): b = io.BytesIO(b'FORM' + struct.pack('>L', 4) + b'AIFF') self.assertRaises(aifc.Error, aifc.open, b) + def test_read_no_ssnd_chunk(self): + b = b'FORM' + struct.pack('>L', 4) + b'AIFC' + b += b'COMM' + struct.pack('>LhlhhLL', 38, 0, 0, 0, 0, 0, 0) + b += b'NONE' + struct.pack('B', 14) + b'not compressed' + b'\x00' + with self.assertRaisesRegex(aifc.Error, 'COMM chunk and/or SSND chunk' + ' missing'): + aifc.open(io.BytesIO(b)) + def test_read_wrong_compression_type(self): b = b'FORM' + struct.pack('>L', 4) + b'AIFC' b += b'COMM' + struct.pack('>LhlhhLL', 23, 0, 0, 0, 0, 0, 0) |