Skip to content

Commit 2cdf66d

Browse files
committed
wave: restore getparams() backward compatibility
1 parent cd49a3b commit 2cdf66d

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

Doc/library/wave.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Wave_read Objects
125125
.. method:: getparams()
126126

127127
Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,
128-
framerate, nframes, comptype, compname, format)``, equivalent to output
128+
framerate, nframes, comptype, compname)``, equivalent to output
129129
of the ``get*()`` methods.
130130

131131

@@ -277,7 +277,7 @@ Wave_write Objects
277277
.. method:: getparams()
278278

279279
Return a :func:`~collections.namedtuple`
280-
``(nchannels, sampwidth, framerate, nframes, comptype, compname, format)``
280+
``(nchannels, sampwidth, framerate, nframes, comptype, compname)``
281281
containing the current output parameters.
282282

283283

Doc/whatsnew/3.15.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,9 +1499,7 @@ wave
14991499
* Added :meth:`wave.Wave_read.getformat`, :meth:`wave.Wave_write.getformat`,
15001500
and :meth:`wave.Wave_write.setformat` for explicit frame format handling.
15011501

1502-
* :meth:`wave.Wave_read.getparams` and :meth:`wave.Wave_write.getparams` now
1503-
include ``format`` as the seventh field in the returned named tuple.
1504-
:meth:`wave.Wave_write.setparams` accepts both 7-item tuples including
1502+
* :meth:`wave.Wave_write.setparams` accepts both 7-item tuples including
15051503
``format`` and 6-item tuples for backwards compatibility (defaulting to
15061504
``WAVE_FORMAT_PCM``).
15071505

Lib/test/audiotests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@ def check_params(self, f, nchannels, sampwidth, framerate, nframes,
3838

3939
params = f.getparams()
4040
self.assertEqual(params,
41-
(nchannels, sampwidth, framerate, nframes, comptype, compname, format))
41+
(nchannels, sampwidth, framerate, nframes, comptype, compname))
4242
self.assertEqual(params.nchannels, nchannels)
4343
self.assertEqual(params.sampwidth, sampwidth)
4444
self.assertEqual(params.framerate, framerate)
4545
self.assertEqual(params.nframes, nframes)
4646
self.assertEqual(params.comptype, comptype)
4747
self.assertEqual(params.compname, compname)
48-
self.assertEqual(params.format, format)
4948

5049
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
5150
dump = pickle.dumps(params, proto)

Lib/test/test_wave.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def test_setparams_7_tuple_uses_format(self):
193193
wave.WAVE_FORMAT_IEEE_FLOAT))
194194
self.assertEqual(w.getformat(), wave.WAVE_FORMAT_IEEE_FLOAT)
195195

196-
def test_getparams_has_format_field(self):
196+
def test_getparams_backward_compatible_shape(self):
197197
with tempfile.NamedTemporaryFile(delete_on_close=False) as fp:
198198
filename = fp.name
199199
self.addCleanup(unlink, filename)
@@ -202,8 +202,7 @@ def test_getparams_has_format_field(self):
202202
w.setparams((1, 2, 22050, 0, 'NONE', 'not compressed',
203203
wave.WAVE_FORMAT_IEEE_FLOAT))
204204
params = w.getparams()
205-
self.assertEqual(params.format, wave.WAVE_FORMAT_IEEE_FLOAT)
206-
self.assertEqual(params[:6], (1, 2, 22050, 0, 'NONE', 'not compressed'))
205+
self.assertEqual(params, (1, 2, 22050, 0, 'NONE', 'not compressed'))
207206

208207
def test_getformat_setformat(self):
209208
with tempfile.NamedTemporaryFile(delete_on_close=False) as fp:

Lib/wave.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ class Error(Exception):
9393
_array_fmts = None, 'b', 'h', None, 'i'
9494

9595
_wave_params = namedtuple('_wave_params',
96-
'nchannels sampwidth framerate nframes comptype compname format',
97-
defaults=(WAVE_FORMAT_PCM,))
96+
'nchannels sampwidth framerate nframes comptype compname')
9897

9998

10099
def _byteswap(data, width):
@@ -350,8 +349,7 @@ def getcompname(self):
350349
def getparams(self):
351350
return _wave_params(self.getnchannels(), self.getsampwidth(),
352351
self.getframerate(), self.getnframes(),
353-
self.getcomptype(), self.getcompname(),
354-
self.getformat())
352+
self.getcomptype(), self.getcompname())
355353

356354
def setpos(self, pos):
357355
if pos < 0 or pos > self._nframes:
@@ -572,7 +570,7 @@ def getparams(self):
572570
if not self._nchannels or not self._sampwidth or not self._framerate:
573571
raise Error('not all parameters set')
574572
return _wave_params(self._nchannels, self._sampwidth, self._framerate,
575-
self._nframes, self._comptype, self._compname, self._format)
573+
self._nframes, self._comptype, self._compname)
576574

577575
def tell(self):
578576
return self._nframeswritten

0 commit comments

Comments
 (0)