[Python-checkins] r84341 - in python/branches/py3k: Doc/library/wave.rst Lib/test/test_wave.py Lib/wave.py Misc/ACKS Misc/NEWS
mark.dickinson
python-checkins at python.org
Sat Aug 28 19:22:17 CEST 2010
Author: mark.dickinson
Date: Sat Aug 28 19:22:16 2010
New Revision: 84341
Log:
Issue #1512791: In setframerate method of Wave_write, round non-integral
inputs to the nearest integer. Thanks Neil Tallim for the patch.
Modified:
python/branches/py3k/Doc/library/wave.rst
python/branches/py3k/Lib/test/test_wave.py
python/branches/py3k/Lib/wave.py
python/branches/py3k/Misc/ACKS
python/branches/py3k/Misc/NEWS
Modified: python/branches/py3k/Doc/library/wave.rst
==============================================================================
--- python/branches/py3k/Doc/library/wave.rst (original)
+++ python/branches/py3k/Doc/library/wave.rst Sat Aug 28 19:22:16 2010
@@ -157,6 +157,10 @@
Set the frame rate to *n*.
+ .. versionchanged:: 3.2
+ A non-integral input to this method is rounded to the nearest
+ integer.
+
.. method:: Wave_write.setnframes(n)
Modified: python/branches/py3k/Lib/test/test_wave.py
==============================================================================
--- python/branches/py3k/Lib/test/test_wave.py (original)
+++ python/branches/py3k/Lib/test/test_wave.py Sat Aug 28 19:22:16 2010
@@ -22,11 +22,14 @@
except OSError:
pass
- def test_it(self):
+ def test_it(self, test_rounding=False):
self.f = wave.open(TESTFN, 'wb')
self.f.setnchannels(nchannels)
self.f.setsampwidth(sampwidth)
- self.f.setframerate(framerate)
+ if test_rounding:
+ self.f.setframerate(framerate - 0.1)
+ else:
+ self.f.setframerate(framerate)
self.f.setnframes(nframes)
output = b'\0' * nframes * nchannels * sampwidth
self.f.writeframes(output)
@@ -39,6 +42,13 @@
self.assertEqual(nframes, self.f.getnframes())
self.assertEqual(self.f.readframes(nframes), output)
+ def test_fractional_framerate(self):
+ """
+ Addresses [ 1512791 ] module wave does no rounding
+ Floating point framerates should be rounded, rather than truncated.
+ """
+ self.test_it(test_rounding=True)
+
def test_issue7681(self):
self.f = wave.open(TESTFN, 'wb')
self.f.setnchannels(nchannels)
Modified: python/branches/py3k/Lib/wave.py
==============================================================================
--- python/branches/py3k/Lib/wave.py (original)
+++ python/branches/py3k/Lib/wave.py Sat Aug 28 19:22:16 2010
@@ -355,7 +355,7 @@
raise Error('cannot change parameters after starting to write')
if framerate <= 0:
raise Error('bad frame rate')
- self._framerate = framerate
+ self._framerate = int(round(framerate))
def getframerate(self):
if not self._framerate:
Modified: python/branches/py3k/Misc/ACKS
==============================================================================
--- python/branches/py3k/Misc/ACKS (original)
+++ python/branches/py3k/Misc/ACKS Sat Aug 28 19:22:16 2010
@@ -792,6 +792,7 @@
Thenault Sylvain
Péter Szabó
Arfrever Frehtes Taifersar Arahesis
+Neil Tallim
Geoff Talvola
Musashi Tamura
William Tanksley
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sat Aug 28 19:22:16 2010
@@ -132,6 +132,9 @@
Library
-------
+- Issue #1512791: In setframerate() in the wave module, non-integral
+ frame rates are rounded to the nearest integer.
+
- Issue #8797: urllib2 does a retry for Basic Authentication failure instead of
falling into recursion.
More information about the Python-checkins
mailing list