mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #19623: Fixed writing to unseekable files in the aifc module.
This commit is contained in:
commit
79f19f9e7c
5 changed files with 27 additions and 40 deletions
11
Lib/aifc.py
11
Lib/aifc.py
|
@ -790,7 +790,10 @@ class Aifc_write:
|
|||
self._datalength = (self._datalength + 3) // 4
|
||||
if self._datalength & 1:
|
||||
self._datalength = self._datalength + 1
|
||||
self._form_length_pos = self._file.tell()
|
||||
try:
|
||||
self._form_length_pos = self._file.tell()
|
||||
except (AttributeError, OSError):
|
||||
self._form_length_pos = None
|
||||
commlength = self._write_form_length(self._datalength)
|
||||
if self._aifc:
|
||||
self._file.write(b'AIFC')
|
||||
|
@ -802,7 +805,8 @@ class Aifc_write:
|
|||
self._file.write(b'COMM')
|
||||
_write_ulong(self._file, commlength)
|
||||
_write_short(self._file, self._nchannels)
|
||||
self._nframes_pos = self._file.tell()
|
||||
if self._form_length_pos is not None:
|
||||
self._nframes_pos = self._file.tell()
|
||||
_write_ulong(self._file, self._nframes)
|
||||
if self._comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'):
|
||||
_write_short(self._file, 8)
|
||||
|
@ -813,7 +817,8 @@ class Aifc_write:
|
|||
self._file.write(self._comptype)
|
||||
_write_string(self._file, self._compname)
|
||||
self._file.write(b'SSND')
|
||||
self._ssnd_length_pos = self._file.tell()
|
||||
if self._form_length_pos is not None:
|
||||
self._ssnd_length_pos = self._file.tell()
|
||||
_write_ulong(self._file, self._datalength + 8)
|
||||
_write_ulong(self._file, 0)
|
||||
_write_ulong(self._file, 0)
|
||||
|
|
|
@ -14,9 +14,6 @@ class AifcTest(audiotests.AudioWriteTests,
|
|||
module = aifc
|
||||
close_fd = True
|
||||
test_unseekable_read = None
|
||||
test_unseekable_write = None
|
||||
test_unseekable_incompleted_write = None
|
||||
test_unseekable_overflowed_write = None
|
||||
|
||||
|
||||
class AifcPCM8Test(AifcTest, unittest.TestCase):
|
||||
|
|
|
@ -6,10 +6,12 @@ import sys
|
|||
import sunau
|
||||
|
||||
|
||||
class SunauPCM8Test(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile,
|
||||
unittest.TestCase):
|
||||
class SunauTest(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile):
|
||||
module = sunau
|
||||
|
||||
|
||||
class SunauPCM8Test(SunauTest, unittest.TestCase):
|
||||
sndfilename = 'pluck-pcm8.au'
|
||||
sndfilenframes = 3307
|
||||
nchannels = 2
|
||||
|
@ -26,10 +28,7 @@ class SunauPCM8Test(audiotests.AudioWriteTests,
|
|||
""")
|
||||
|
||||
|
||||
class SunauPCM16Test(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile,
|
||||
unittest.TestCase):
|
||||
module = sunau
|
||||
class SunauPCM16Test(SunauTest, unittest.TestCase):
|
||||
sndfilename = 'pluck-pcm16.au'
|
||||
sndfilenframes = 3307
|
||||
nchannels = 2
|
||||
|
@ -48,10 +47,7 @@ class SunauPCM16Test(audiotests.AudioWriteTests,
|
|||
""")
|
||||
|
||||
|
||||
class SunauPCM24Test(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile,
|
||||
unittest.TestCase):
|
||||
module = sunau
|
||||
class SunauPCM24Test(SunauTest, unittest.TestCase):
|
||||
sndfilename = 'pluck-pcm24.au'
|
||||
sndfilenframes = 3307
|
||||
nchannels = 2
|
||||
|
@ -76,10 +72,7 @@ class SunauPCM24Test(audiotests.AudioWriteTests,
|
|||
""")
|
||||
|
||||
|
||||
class SunauPCM32Test(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile,
|
||||
unittest.TestCase):
|
||||
module = sunau
|
||||
class SunauPCM32Test(SunauTest, unittest.TestCase):
|
||||
sndfilename = 'pluck-pcm32.au'
|
||||
sndfilenframes = 3307
|
||||
nchannels = 2
|
||||
|
@ -104,10 +97,7 @@ class SunauPCM32Test(audiotests.AudioWriteTests,
|
|||
""")
|
||||
|
||||
|
||||
class SunauULAWTest(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile,
|
||||
unittest.TestCase):
|
||||
module = sunau
|
||||
class SunauULAWTest(SunauTest, unittest.TestCase):
|
||||
sndfilename = 'pluck-ulaw.au'
|
||||
sndfilenframes = 3307
|
||||
nchannels = 2
|
||||
|
|
|
@ -6,10 +6,12 @@ import sys
|
|||
import wave
|
||||
|
||||
|
||||
class WavePCM8Test(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile,
|
||||
unittest.TestCase):
|
||||
class WaveTest(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile):
|
||||
module = wave
|
||||
|
||||
|
||||
class WavePCM8Test(WaveTest, unittest.TestCase):
|
||||
sndfilename = 'pluck-pcm8.wav'
|
||||
sndfilenframes = 3307
|
||||
nchannels = 2
|
||||
|
@ -26,10 +28,7 @@ class WavePCM8Test(audiotests.AudioWriteTests,
|
|||
""")
|
||||
|
||||
|
||||
class WavePCM16Test(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile,
|
||||
unittest.TestCase):
|
||||
module = wave
|
||||
class WavePCM16Test(WaveTest, unittest.TestCase):
|
||||
sndfilename = 'pluck-pcm16.wav'
|
||||
sndfilenframes = 3307
|
||||
nchannels = 2
|
||||
|
@ -50,10 +49,7 @@ class WavePCM16Test(audiotests.AudioWriteTests,
|
|||
frames = byteswap(frames, 2)
|
||||
|
||||
|
||||
class WavePCM24Test(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile,
|
||||
unittest.TestCase):
|
||||
module = wave
|
||||
class WavePCM24Test(WaveTest, unittest.TestCase):
|
||||
sndfilename = 'pluck-pcm24.wav'
|
||||
sndfilenframes = 3307
|
||||
nchannels = 2
|
||||
|
@ -80,10 +76,7 @@ class WavePCM24Test(audiotests.AudioWriteTests,
|
|||
frames = byteswap(frames, 3)
|
||||
|
||||
|
||||
class WavePCM32Test(audiotests.AudioWriteTests,
|
||||
audiotests.AudioTestsWithSourceFile,
|
||||
unittest.TestCase):
|
||||
module = wave
|
||||
class WavePCM32Test(WaveTest, unittest.TestCase):
|
||||
sndfilename = 'pluck-pcm32.wav'
|
||||
sndfilenframes = 3307
|
||||
nchannels = 2
|
||||
|
|
|
@ -44,6 +44,8 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #19623: Fixed writing to unseekable files in the aifc module.
|
||||
|
||||
- Issue #19946: multiprocessing.spawn now raises ImportError when the module to
|
||||
be used as the main module cannot be imported.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue