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

index 2c386a5dff9c4094ba893de85081609c56fcce1f..a1daead8abde041ce9f15c245c541c1814ec287c 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 7744958e3027e663e22f75a58b4e83edda6676cf..ebc7d4c4bfcbf2d5910b77371006a5170283a91b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -76,6 +76,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #19276: Fixed the wave module on 64-bit big-endian platforms.
+
 - Issue #18776: atexit callbacks now display their full traceback when they
   raise an exception.