[Python-checkins] cpython (merge 3.3 -> default): Issue #19623: Fixed writing to unseekable files in the aifc module.
serhiy.storchaka
python-checkins at python.org
Sat Dec 14 19:43:27 CET 2013
http://hg.python.org/cpython/rev/804406d79b45
changeset: 87958:804406d79b45
parent: 87955:2fbb3c77f157
parent: 87957:35f6a5937a63
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sat Dec 14 20:42:22 2013 +0200
summary:
Issue #19623: Fixed writing to unseekable files in the aifc module.
files:
Lib/aifc.py | 11 ++++++++---
Lib/test/test_aifc.py | 3 ---
Lib/test/test_sunau.py | 28 +++++++++-------------------
Lib/test/test_wave.py | 23 ++++++++---------------
Misc/NEWS | 2 ++
5 files changed, 27 insertions(+), 40 deletions(-)
diff --git a/Lib/aifc.py b/Lib/aifc.py
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -790,7 +790,10 @@
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 @@
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 @@
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)
diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py
--- a/Lib/test/test_aifc.py
+++ b/Lib/test/test_aifc.py
@@ -14,9 +14,6 @@
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):
diff --git a/Lib/test/test_sunau.py b/Lib/test/test_sunau.py
--- a/Lib/test/test_sunau.py
+++ b/Lib/test/test_sunau.py
@@ -6,10 +6,12 @@
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 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 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 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 SunauULAWTest(audiotests.AudioWriteTests,
- audiotests.AudioTestsWithSourceFile,
- unittest.TestCase):
- module = sunau
+class SunauULAWTest(SunauTest, unittest.TestCase):
sndfilename = 'pluck-ulaw.au'
sndfilenframes = 3307
nchannels = 2
diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py
--- a/Lib/test/test_wave.py
+++ b/Lib/test/test_wave.py
@@ -6,10 +6,12 @@
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 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 @@
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 @@
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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -44,6 +44,8 @@
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.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list