Skip to content

Commit d3b7505

Browse files
Issue #19276: Fixed the wave module on 64-bit big-endian platforms.
1 parent 9ff06dc commit d3b7505

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/wave.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Error(Exception):
8080

8181
WAVE_FORMAT_PCM = 0x0001
8282

83-
_array_fmts = None, 'b', 'h', None, 'l'
83+
_array_fmts = None, 'b', 'h', None, 'i'
8484

8585
# Determine endian-ness
8686
import struct
@@ -238,6 +238,7 @@ def readframes(self, nframes):
238238
import array
239239
chunk = self._data_chunk
240240
data = array.array(_array_fmts[self._sampwidth])
241+
assert data.itemsize == self._sampwidth
241242
nitems = nframes * self._nchannels
242243
if nitems * self._sampwidth > chunk.chunksize - chunk.size_read:
243244
nitems = (chunk.chunksize - chunk.size_read) // self._sampwidth
@@ -421,6 +422,7 @@ def writeframesraw(self, data):
421422
if self._sampwidth > 1 and big_endian:
422423
import array
423424
data = array.array(_array_fmts[self._sampwidth], data)
425+
assert data.itemsize == self._sampwidth
424426
data.byteswap()
425427
data.tofile(self._file)
426428
self._datawritten = self._datawritten + len(data) * self._sampwidth

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Core and Builtins
7676
Library
7777
-------
7878

79+
- Issue #19276: Fixed the wave module on 64-bit big-endian platforms.
80+
7981
- Issue #18776: atexit callbacks now display their full traceback when they
8082
raise an exception.
8183

0 commit comments

Comments
 (0)