[Python-checkins] r77460 - in python/branches/release31-maint: Lib/test/test_wave.py Lib/wave.py Misc/NEWS
benjamin.peterson
python-checkins at python.org
Wed Jan 13 04:53:15 CET 2010
Author: benjamin.peterson
Date: Wed Jan 13 04:53:14 2010
New Revision: 77460
Log:
Merged revisions 77459 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r77459 | benjamin.peterson | 2010-01-12 21:49:50 -0600 (Tue, 12 Jan 2010) | 1 line
use floor division where needed #7681
........
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Lib/test/test_wave.py
python/branches/release31-maint/Lib/wave.py
python/branches/release31-maint/Misc/NEWS
Modified: python/branches/release31-maint/Lib/test/test_wave.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_wave.py (original)
+++ python/branches/release31-maint/Lib/test/test_wave.py Wed Jan 13 04:53:14 2010
@@ -1,6 +1,7 @@
from test.support import TESTFN, run_unittest
import os
import wave
+import struct
import unittest
nchannels = 2
@@ -38,6 +39,16 @@
self.assertEqual(nframes, self.f.getnframes())
self.assertEqual(self.f.readframes(nframes), output)
+ def test_issue7681(self):
+ self.f = wave.open(TESTFN, 'wb')
+ self.f.setnchannels(nchannels)
+ self.f.setsampwidth(sampwidth)
+ self.f.setframerate(framerate)
+ # Don't call setnframes, make _write_header divide to figure it out
+ output = b'\0' * nframes * nchannels * sampwidth
+ self.f.writeframes(output)
+
+
def test_main():
run_unittest(TestWave)
Modified: python/branches/release31-maint/Lib/wave.py
==============================================================================
--- python/branches/release31-maint/Lib/wave.py (original)
+++ python/branches/release31-maint/Lib/wave.py Wed Jan 13 04:53:14 2010
@@ -240,7 +240,7 @@
data = array.array(_array_fmts[self._sampwidth])
nitems = nframes * self._nchannels
if nitems * self._sampwidth > chunk.chunksize - chunk.size_read:
- nitems = (chunk.chunksize - chunk.size_read) / self._sampwidth
+ nitems = (chunk.chunksize - chunk.size_read) // self._sampwidth
data.fromfile(chunk.file.file, nitems)
# "tell" data chunk how much was read
chunk.size_read = chunk.size_read + nitems * self._sampwidth
@@ -461,7 +461,7 @@
def _write_header(self, initlength):
self._file.write(b'RIFF')
if not self._nframes:
- self._nframes = initlength / (self._nchannels * self._sampwidth)
+ 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',
Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS (original)
+++ python/branches/release31-maint/Misc/NEWS Wed Jan 13 04:53:14 2010
@@ -65,6 +65,8 @@
Library
-------
+- Issue #7681: Use floor division in appropiate places in the wave module.
+
- Issue #5372: Drop the reuse of .o files in Distutils' ccompiler (since
Extension extra options may change the output without changing the .c
file). Initial patch by Collin Winter.
More information about the Python-checkins
mailing list