]> granicus.if.org Git - python/commitdiff
Issue #19276: Fixed the wave module on 64-bit big-endian platforms.
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 17 Oct 2013 20:03:48 +0000 (23:03 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 17 Oct 2013 20:03:48 +0000 (23:03 +0300)
Lib/wave.py
Misc/NEWS

index 04a1a6db38c643b9c8d701fdce99b31928d7fa20..d6eef782412faa7cc7228ab052339e468103ed58 100644 (file)
@@ -80,7 +80,7 @@ class Error(Exception):
 
 WAVE_FORMAT_PCM = 0x0001
 
-_array_fmts = None, 'b', 'h', None, 'l'
+_array_fmts = None, 'b', 'h', None, 'i'
 
 # Determine endian-ness
 import struct
@@ -238,6 +238,7 @@ class Wave_read:
             import array
             chunk = self._data_chunk
             data = array.array(_array_fmts[self._sampwidth])
+            assert data.itemsize == self._sampwidth
             nitems = nframes * self._nchannels
             if nitems * self._sampwidth > chunk.chunksize - chunk.size_read:
                 nitems = (chunk.chunksize - chunk.size_read) / self._sampwidth
@@ -421,6 +422,7 @@ class Wave_write:
         if self._sampwidth > 1 and big_endian:
             import array
             data = array.array(_array_fmts[self._sampwidth], data)
+            assert data.itemsize == self._sampwidth
             data.byteswap()
             data.tofile(self._file)
             self._datawritten = self._datawritten + len(data) * self._sampwidth
index 6e4b7fb8565b4358f0f56cabf35e9d4b0ac89759..8af97535a5fdaeb8350594248aaf4b250a1646de 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -35,6 +35,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #19276: Fixed the wave module on 64-bit big-endian platforms.
+
 - Issue #18458: Prevent crashes with newer versions of libedit.  Its readline
   emulation has changed from 0-based indexing to 1-based like gnu readline.
   Original patch by Ronald Oussoren.