diff options
author | Sandro Tosi <sandro.tosi@gmail.com> | 2012-01-01 17:05:06 (GMT) |
---|---|---|
committer | Sandro Tosi <sandro.tosi@gmail.com> | 2012-01-01 17:05:06 (GMT) |
commit | 35e0275e591b2ebda207040c1e226dd59aaa0a6c (patch) | |
tree | 45c33b8d27610a92055386cc310b3713d4fdea86 /Lib | |
parent | 245537a84d8474d64c7613c4f11649e43159d0e3 (diff) | |
parent | bdd5354700d2ebafc98375ef2982fbcbb42b1ba5 (diff) | |
download | cpython-35e0275e591b2ebda207040c1e226dd59aaa0a6c.zip cpython-35e0275e591b2ebda207040c1e226dd59aaa0a6c.tar.gz cpython-35e0275e591b2ebda207040c1e226dd59aaa0a6c.tar.bz2 |
merge with 3.2
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/aifc.py | 12 | ||||
-rw-r--r-- | Lib/test/test_aifc.py | 11 |
2 files changed, 13 insertions, 10 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py index 015d398..4646285 100644 --- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -716,18 +716,12 @@ class Aifc_write: def _ensure_header_written(self, datasize): if not self._nframeswritten: - if self._comptype in (b'ULAW', b'ALAW'): + if self._comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'): if not self._sampwidth: self._sampwidth = 2 if self._sampwidth != 2: raise Error('sample width must be 2 when compressing ' - 'with ulaw/ULAW or alaw/ALAW') - if self._comptype == b'G722': - if not self._sampwidth: - self._sampwidth = 2 - if self._sampwidth != 2: - raise Error('sample width must be 2 when compressing ' - 'with G7.22 (ADPCM)') + 'with ulaw/ULAW, alaw/ALAW or G7.22 (ADPCM)') if not self._nchannels: raise Error('# channels not specified') if not self._sampwidth: @@ -743,8 +737,6 @@ class Aifc_write: self._convert = self._lin2ulaw elif self._comptype in (b'alaw', b'ALAW'): self._convert = self._lin2alaw - else: - raise Error('unsupported compression type') def _write_header(self, initlength): if self._aifc and self._comptype != b'NONE': diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py index 4869bf3..af2305f 100644 --- a/Lib/test/test_aifc.py +++ b/Lib/test/test_aifc.py @@ -1,6 +1,7 @@ from test.support import findfile, run_unittest, TESTFN import unittest import os +import io import aifc @@ -109,6 +110,16 @@ class AIFCTest(unittest.TestCase): f.close() self.assertEqual(testfile.closed, True) + def test_write_header_comptype_sampwidth(self): + for comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'): + fout = self.fout = aifc.open(io.BytesIO(), 'wb') + fout.setnchannels(1) + fout.setframerate(1) + fout.setcomptype(comptype, b'') + fout.close() + self.assertEqual(fout.getsampwidth(), 2) + fout.initfp(None) + def test_main(): run_unittest(AIFCTest) |