Skip to content

Commit 495a8d3

Browse files
committed
gh-105096: Deprecate wave getmarkers() method
wave: Deprecate the getmark(), setmark() and getmarkers() methods of the Wave_read and Wave_write classes. They will be removed in Python 3.15.
1 parent 0656d23 commit 495a8d3

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

Doc/library/wave.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,19 @@ module, and don't do anything interesting.
127127

128128
Returns ``None``.
129129

130+
.. deprecated-removed:: 3.13 3.15
131+
The method only existed for compatibility with the :mod:`!aifc` module
132+
which has been removed in Python 3.13.
133+
130134

131135
.. method:: Wave_read.getmark(id)
132136

133137
Raise an error.
134138

139+
.. deprecated-removed:: 3.13 3.15
140+
The method only existed for compatibility with the :mod:`!aifc` module
141+
which has been removed in Python 3.13.
142+
135143
The following two methods define a term "position" which is compatible between
136144
them, and is otherwise implementation dependent.
137145

Doc/whatsnew/3.13.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ Optimizations
103103
Deprecated
104104
==========
105105

106+
* :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()``
107+
methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes.
108+
They will be removed in Python 3.15.
109+
(Contributed by Victor Stinner in :gh:`105096`.)
106110

107111

108112
Removed

Lib/test/test_wave.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,32 @@ def test__all__(self):
136136
not_exported = {'WAVE_FORMAT_PCM', 'WAVE_FORMAT_EXTENSIBLE', 'KSDATAFORMAT_SUBTYPE_PCM'}
137137
support.check__all__(self, wave, not_exported=not_exported)
138138

139+
def test_read_deprecations(self):
140+
filename = support.findfile('pluck-pcm8.wav', subdir='audiodata')
141+
with wave.open(filename) as reader:
142+
with self.assertWarns(DeprecationWarning):
143+
with self.assertRaises(wave.Error):
144+
reader.getmark('mark')
145+
with self.assertWarns(DeprecationWarning):
146+
self.assertIsNone(reader.getmarkers())
147+
148+
def test_write_deprecations(self):
149+
with io.BytesIO(b'') as tmpfile:
150+
with wave.open(tmpfile, 'wb') as writer:
151+
writer.setnchannels(1)
152+
writer.setsampwidth(1)
153+
writer.setframerate(1)
154+
writer.setcomptype('NONE', 'not compressed')
155+
156+
with self.assertWarns(DeprecationWarning):
157+
with self.assertRaises(wave.Error):
158+
writer.setmark(0, 0, 'mark')
159+
with self.assertWarns(DeprecationWarning):
160+
with self.assertRaises(wave.Error):
161+
writer.getmark('mark')
162+
with self.assertWarns(DeprecationWarning):
163+
self.assertIsNone(writer.getmarkers())
164+
139165

140166
class WaveLowLevelTest(unittest.TestCase):
141167

Lib/wave.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,13 @@ def getparams(self):
343343
self.getcomptype(), self.getcompname())
344344

345345
def getmarkers(self):
346+
import warnings
347+
warnings._deprecated("Wave_read.getmarkers", remove=(3, 15))
346348
return None
347349

348350
def getmark(self, id):
351+
import warnings
352+
warnings._deprecated("Wave_read.getmark", remove=(3, 15))
349353
raise Error('no marks')
350354

351355
def setpos(self, pos):
@@ -548,12 +552,18 @@ def getparams(self):
548552
self._nframes, self._comptype, self._compname)
549553

550554
def setmark(self, id, pos, name):
555+
import warnings
556+
warnings._deprecated("Wave_write.setmark", remove=(3, 15))
551557
raise Error('setmark() not supported')
552558

553559
def getmark(self, id):
560+
import warnings
561+
warnings._deprecated("Wave_write.getmark", remove=(3, 15))
554562
raise Error('no marks')
555563

556564
def getmarkers(self):
565+
import warnings
566+
warnings._deprecated("Wave_write.getmarkers", remove=(3, 15))
557567
return None
558568

559569
def tell(self):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()``
2+
methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes.
3+
They will be removed in Python 3.15. Patch by Victor Stinner.

0 commit comments

Comments
 (0)