[Python-checkins] cpython (3.3): Issue #19276: Fixed the wave module on 64-bit big-endian platforms.

serhiy.storchaka python-checkins at python.org
Thu Oct 17 22:05:53 CEST 2013


http://hg.python.org/cpython/rev/a1a4a527c699
changeset:   86411:a1a4a527c699
branch:      3.3
parent:      86408:0fff9feb4bdf
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Thu Oct 17 23:04:04 2013 +0300
summary:
  Issue #19276: Fixed the wave module on 64-bit big-endian platforms.

files:
  Lib/wave.py |  4 +++-
  Misc/NEWS   |  2 ++
  2 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Lib/wave.py b/Lib/wave.py
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -80,7 +80,7 @@
 
 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 @@
             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 @@
         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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -76,6 +76,8 @@
 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.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list