Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-105096: Deprecate wave getmarkers() method #105098

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Doc/library/wave.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,19 @@ Wave_read Objects

Returns ``None``.

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


.. method:: getmark(id)

Raise an error.

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

The following two methods define a term "position" which is compatible between
them, and is otherwise implementation dependent.

Expand Down
4 changes: 4 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ Optimizations
Deprecated
==========

* :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()``
methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes.
hugovk marked this conversation as resolved.
Show resolved Hide resolved
They will be removed in Python 3.15.
(Contributed by Victor Stinner in :gh:`105096`.)


Removed
Expand Down
26 changes: 26 additions & 0 deletions Lib/test/test_wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,32 @@ def test__all__(self):
not_exported = {'WAVE_FORMAT_PCM', 'WAVE_FORMAT_EXTENSIBLE', 'KSDATAFORMAT_SUBTYPE_PCM'}
support.check__all__(self, wave, not_exported=not_exported)

def test_read_deprecations(self):
filename = support.findfile('pluck-pcm8.wav', subdir='audiodata')
with wave.open(filename) as reader:
with self.assertWarns(DeprecationWarning):
with self.assertRaises(wave.Error):
reader.getmark('mark')
with self.assertWarns(DeprecationWarning):
self.assertIsNone(reader.getmarkers())

def test_write_deprecations(self):
with io.BytesIO(b'') as tmpfile:
with wave.open(tmpfile, 'wb') as writer:
writer.setnchannels(1)
writer.setsampwidth(1)
writer.setframerate(1)
writer.setcomptype('NONE', 'not compressed')

with self.assertWarns(DeprecationWarning):
with self.assertRaises(wave.Error):
writer.setmark(0, 0, 'mark')
with self.assertWarns(DeprecationWarning):
with self.assertRaises(wave.Error):
writer.getmark('mark')
with self.assertWarns(DeprecationWarning):
self.assertIsNone(writer.getmarkers())


class WaveLowLevelTest(unittest.TestCase):

Expand Down
10 changes: 10 additions & 0 deletions Lib/wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,13 @@ def getparams(self):
self.getcomptype(), self.getcompname())

def getmarkers(self):
import warnings
warnings._deprecated("Wave_read.getmarkers", remove=(3, 15))
return None

def getmark(self, id):
import warnings
warnings._deprecated("Wave_read.getmark", remove=(3, 15))
raise Error('no marks')

def setpos(self, pos):
Expand Down Expand Up @@ -548,12 +552,18 @@ def getparams(self):
self._nframes, self._comptype, self._compname)

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

def getmark(self, id):
import warnings
warnings._deprecated("Wave_write.getmark", remove=(3, 15))
raise Error('no marks')

def getmarkers(self):
import warnings
warnings._deprecated("Wave_write.getmarkers", remove=(3, 15))
return None

def tell(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()``
methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes.
They will be removed in Python 3.15. Patch by Victor Stinner.