Skip to content

Commit 03ad662

Browse files
authored
gh-105096: Deprecate wave getmarkers() method (#105098)
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 58a2e09 commit 03ad662

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
@@ -131,11 +131,19 @@ Wave_read Objects
131131

132132
Returns ``None``.
133133

134+
.. deprecated-removed:: 3.13 3.15
135+
The method only existed for compatibility with the :mod:`!aifc` module
136+
which has been removed in Python 3.13.
137+
134138

135139
.. method:: getmark(id)
136140

137141
Raise an error.
138142

143+
.. deprecated-removed:: 3.13 3.15
144+
The method only existed for compatibility with the :mod:`!aifc` module
145+
which has been removed in Python 3.13.
146+
139147
The following two methods define a term "position" which is compatible between
140148
them, and is otherwise implementation dependent.
141149

Doc/whatsnew/3.13.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ Optimizations
115115
Deprecated
116116
==========
117117

118+
* :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()``
119+
methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes.
120+
They will be removed in Python 3.15.
121+
(Contributed by Victor Stinner in :gh:`105096`.)
118122

119123

120124
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
@@ -342,9 +342,13 @@ def getparams(self):
342342
self.getcomptype(), self.getcompname())
343343

344344
def getmarkers(self):
345+
import warnings
346+
warnings._deprecated("Wave_read.getmarkers", remove=(3, 15))
345347
return None
346348

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

350354
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)