[Python-checkins] cpython (2.7): Closes #16461: Wave library should be able to deal with 4GB wav files, and
jesus.cea
python-checkins at python.org
Sat Nov 17 03:43:31 CET 2012
http://hg.python.org/cpython/rev/b8ece33ce27d
changeset: 80455:b8ece33ce27d
branch: 2.7
parent: 80439:457c0c9c7893
user: Jesus Cea <jcea at jcea.es>
date: Sat Nov 17 03:38:17 2012 +0100
summary:
Closes #16461: Wave library should be able to deal with 4GB wav files, and sample rate of 44100 Hz.
files:
Lib/wave.py | 12 ++++++------
Misc/NEWS | 3 +++
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/Lib/wave.py b/Lib/wave.py
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -261,9 +261,9 @@
#
def _read_fmt_chunk(self, chunk):
- wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack('<hhllh', chunk.read(14))
+ wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack('<HHLLH', chunk.read(14))
if wFormatTag == WAVE_FORMAT_PCM:
- sampwidth = struct.unpack('<h', chunk.read(2))[0]
+ sampwidth = struct.unpack('<H', chunk.read(2))[0]
self._sampwidth = (sampwidth + 7) // 8
else:
raise Error, 'unknown format: %r' % (wFormatTag,)
@@ -466,14 +466,14 @@
self._nframes = initlength / (self._nchannels * self._sampwidth)
self._datalength = self._nframes * self._nchannels * self._sampwidth
self._form_length_pos = self._file.tell()
- self._file.write(struct.pack('<l4s4slhhllhh4s',
+ self._file.write(struct.pack('<L4s4sLHHLLHH4s',
36 + self._datalength, 'WAVE', 'fmt ', 16,
WAVE_FORMAT_PCM, self._nchannels, self._framerate,
self._nchannels * self._framerate * self._sampwidth,
self._nchannels * self._sampwidth,
self._sampwidth * 8, 'data'))
self._data_length_pos = self._file.tell()
- self._file.write(struct.pack('<l', self._datalength))
+ self._file.write(struct.pack('<L', self._datalength))
self._headerwritten = True
def _patchheader(self):
@@ -482,9 +482,9 @@
return
curpos = self._file.tell()
self._file.seek(self._form_length_pos, 0)
- self._file.write(struct.pack('<l', 36 + self._datawritten))
+ self._file.write(struct.pack('<L', 36 + self._datawritten))
self._file.seek(self._data_length_pos, 0)
- self._file.write(struct.pack('<l', self._datawritten))
+ self._file.write(struct.pack('<L', self._datawritten))
self._file.seek(curpos, 0)
self._datalength = self._datawritten
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -188,6 +188,9 @@
- Issue #16220: wsgiref now always calls close() on an iterable response.
Patch by Brent Tubbs.
+- Issue #16461: Wave library should be able to deal with 4GB wav files,
+ and sample rate of 44100 Hz.
+
- Issue #16176: Properly identify Windows 8 via platform.platform()
- Issue #15756: subprocess.poll() now properly handles errno.ECHILD to
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list