From d9a018222f4a885ca3eeee41a77103f5462e3813 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 21 Nov 2013 11:02:30 +0200 Subject: [PATCH] Issue #19633: Fixed writing not compressed 16- and 32-bit wave files on big-endian platforms. Temporary forbidden test_unseekable_incompleted_write fornot compressed 16- and 32-bit wave file on big-endian platforms. --- Lib/test/audiotests.py | 6 ++++-- Lib/test/test_wave.py | 11 +++++++++++ Lib/wave.py | 4 +++- Misc/NEWS | 3 +++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Lib/test/audiotests.py b/Lib/test/audiotests.py index 59e9928796d..008281f9af2 100644 --- a/Lib/test/audiotests.py +++ b/Lib/test/audiotests.py @@ -6,7 +6,8 @@ import pickle import sys def byteswap2(data): - a = array.array('h', data) + a = array.array('h') + a.frombytes(data) a.byteswap() return a.tobytes() @@ -17,7 +18,8 @@ def byteswap3(data): return bytes(ba) def byteswap4(data): - a = array.array('i', data) + a = array.array('i') + a.frombytes(data) a.byteswap() return a.tobytes() diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py index cf069ae7713..5be12519d9e 100644 --- a/Lib/test/test_wave.py +++ b/Lib/test/test_wave.py @@ -48,6 +48,12 @@ class WavePCM16Test(audiotests.AudioWriteTests, if sys.byteorder != 'big': frames = audiotests.byteswap2(frames) + if sys.byteorder == 'big': + @unittest.expectedFailure + def test_unseekable_incompleted_write(self): + super().test_unseekable_incompleted_write() + + class WavePCM24Test(audiotests.AudioWriteTests, audiotests.AudioTestsWithSourceFile, @@ -108,6 +114,11 @@ class WavePCM32Test(audiotests.AudioWriteTests, if sys.byteorder != 'big': frames = audiotests.byteswap4(frames) + if sys.byteorder == 'big': + @unittest.expectedFailure + def test_unseekable_incompleted_write(self): + super().test_unseekable_incompleted_write() + if __name__ == '__main__': unittest.main() diff --git a/Lib/wave.py b/Lib/wave.py index 6285c748765..4a223451bf9 100644 --- a/Lib/wave.py +++ b/Lib/wave.py @@ -424,7 +424,9 @@ class Wave_write: data = self._convert(data) if self._sampwidth in (2, 4) and sys.byteorder == 'big': import array - data = array.array(_array_fmts[self._sampwidth], data) + a = array.array(_array_fmts[self._sampwidth]) + a.frombytes(data) + data = a assert data.itemsize == self._sampwidth data.byteswap() data.tofile(self._file) diff --git a/Misc/NEWS b/Misc/NEWS index 28d80c20edd..12f3b526230 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -13,6 +13,9 @@ Core and Builtins Library ------- +- Issue #19633: Fixed writing not compressed 16- and 32-bit wave files on + big-endian platforms. + - Issue #19449: in csv's writerow, handle non-string keys when generating the error message that certain keys are not in the 'fieldnames' list.