Skip to content

Commit c57e3ee

Browse files
vstinnerlisroach
authored andcommitted
bpo-37320: Remove openfp() of aifc, sunau and wave (pythonGH-14169)
aifc.openfp() alias to aifc.open(), sunau.openfp() alias to sunau.open(), and wave.openfp() alias to wave.open() have been removed. They were deprecated since Python 3.7.
1 parent e540902 commit c57e3ee

File tree

12 files changed

+29
-69
lines changed

12 files changed

+29
-69
lines changed

Doc/library/sunau.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ The :mod:`sunau` module defines the following functions:
5959
or ``'wb'`` returns an :class:`AU_write` object.
6060

6161

62-
.. function:: openfp(file, mode)
63-
64-
A synonym for :func:`.open`, maintained for backwards compatibility.
65-
66-
.. deprecated-removed:: 3.7 3.9
67-
68-
6962
The :mod:`sunau` module defines the following exception:
7063

7164
.. exception:: Error

Doc/library/wave.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ The :mod:`wave` module defines the following function and exception:
4747
.. versionchanged:: 3.4
4848
Added support for unseekable files.
4949

50-
.. function:: openfp(file, mode)
51-
52-
A synonym for :func:`.open`, maintained for backwards compatibility.
53-
54-
.. deprecated-removed:: 3.7 3.9
55-
56-
5750
.. exception:: Error
5851

5952
An error raised when something is impossible because it violates the WAV

Doc/whatsnew/3.9.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,14 @@ Deprecated
122122
Removed
123123
=======
124124

125-
``_dummy_thread`` and ``dummy_threading`` modules have been removed. These
126-
modules were deprecated since Python 3.7 which requires threading support.
127-
(Contributed by Victor Stinner in :issue:`37312`.)
125+
* ``_dummy_thread`` and ``dummy_threading`` modules have been removed. These
126+
modules were deprecated since Python 3.7 which requires threading support.
127+
(Contributed by Victor Stinner in :issue:`37312`.)
128+
129+
* ``aifc.openfp()`` alias to ``aifc.open()``, ``sunau.openfp()`` alias to
130+
``sunau.open()``, and ``wave.openfp()`` alias to ``wave.open()`` have been
131+
removed. They were deprecated since Python 3.7.
132+
(Contributed by Victor Stinner in :issue:`37320`.)
128133

129134

130135
Porting to Python 3.9

Lib/aifc.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
import builtins
139139
import warnings
140140

141-
__all__ = ["Error", "open", "openfp"]
141+
__all__ = ["Error", "open"]
142142

143143
class Error(Exception):
144144
pass
@@ -920,10 +920,6 @@ def open(f, mode=None):
920920
else:
921921
raise Error("mode must be 'r', 'rb', 'w', or 'wb'")
922922

923-
def openfp(f, mode=None):
924-
warnings.warn("aifc.openfp is deprecated since Python 3.7. "
925-
"Use aifc.open instead.", DeprecationWarning, stacklevel=2)
926-
return open(f, mode=mode)
927923

928924
if __name__ == '__main__':
929925
import sys

Lib/sunau.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"""
105105

106106
from collections import namedtuple
107-
import warnings
107+
108108

109109
_sunau_params = namedtuple('_sunau_params',
110110
'nchannels sampwidth framerate nframes comptype compname')
@@ -524,8 +524,3 @@ def open(f, mode=None):
524524
return Au_write(f)
525525
else:
526526
raise Error("mode must be 'r', 'rb', 'w', or 'wb'")
527-
528-
def openfp(f, mode=None):
529-
warnings.warn("sunau.openfp is deprecated since Python 3.7. "
530-
"Use sunau.open instead.", DeprecationWarning, stacklevel=2)
531-
return open(f, mode=mode)

Lib/test/audiotests.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from test.support import findfile, TESTFN, unlink
22
import array
33
import io
4-
from unittest import mock
54
import pickle
65

76

@@ -50,17 +49,6 @@ def check_params(self, f, nchannels, sampwidth, framerate, nframes,
5049
self.assertEqual(pickle.loads(dump), params)
5150

5251

53-
class AudioMiscTests(AudioTests):
54-
55-
def test_openfp_deprecated(self):
56-
arg = "arg"
57-
mode = "mode"
58-
with mock.patch(f"{self.module.__name__}.open") as mock_open, \
59-
self.assertWarns(DeprecationWarning):
60-
self.module.openfp(arg, mode=mode)
61-
mock_open.assert_called_with(arg, mode=mode)
62-
63-
6452
class AudioWriteTests(AudioTests):
6553

6654
def create_file(self, testfile):

Lib/test/test_aifc.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,12 @@ class AifcALAWTest(AifcTest, unittest.TestCase):
143143
frames = byteswap(frames, 2)
144144

145145

146-
class AifcMiscTest(audiotests.AudioMiscTests, unittest.TestCase):
147-
module = aifc
148-
146+
class AifcMiscTest(unittest.TestCase):
149147
def test_skipunknown(self):
150148
#Issue 2245
151149
#This file contains chunk types aifc doesn't recognize.
152-
self.f = aifc.open(findfile('Sine-1000Hz-300ms.aif'))
150+
f = aifc.open(findfile('Sine-1000Hz-300ms.aif'))
151+
f.close()
153152

154153
def test_close_opened_files_on_error(self):
155154
non_aifc_file = findfile('pluck-pcm8.wav', subdir='audiodata')
@@ -172,7 +171,8 @@ def test_params_added(self):
172171
f.setparams((1, 1, 1, 1, b'NONE', b''))
173172
f.close()
174173

175-
f = self.f = aifc.open(TESTFN, 'rb')
174+
f = aifc.open(TESTFN, 'rb')
175+
self.addCleanup(f.close)
176176
params = f.getparams()
177177
self.assertEqual(params.nchannels, f.getnchannels())
178178
self.assertEqual(params.sampwidth, f.getsampwidth())
@@ -208,7 +208,8 @@ def test_read_markers(self):
208208
fout.setmark(2, 0, b'even')
209209
fout.writeframes(b'\x00')
210210
fout.close()
211-
f = self.f = aifc.open(TESTFN, 'rb')
211+
f = aifc.open(TESTFN, 'rb')
212+
self.addCleanup(f.close)
212213
self.assertEqual(f.getmarkers(), [(1, 0, b'odd'), (2, 0, b'even')])
213214
self.assertEqual(f.getmark(1), (1, 0, b'odd'))
214215
self.assertEqual(f.getmark(2), (2, 0, b'even'))

Lib/test/test_pyclbr.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,7 @@ def test_others(self):
225225
cm('random', ignore=('Random',)) # from _random import Random as CoreGenerator
226226
cm('cgi', ignore=('log',)) # set with = in module
227227
cm('pickle', ignore=('partial', 'PickleBuffer'))
228-
# TODO(briancurtin): openfp is deprecated as of 3.7.
229-
# Update this once it has been removed.
230-
cm('aifc', ignore=('openfp', '_aifc_params')) # set with = in module
228+
cm('aifc', ignore=('_aifc_params',)) # set with = in module
231229
cm('sre_parse', ignore=('dump', 'groups', 'pos')) # from sre_constants import *; property
232230
cm('pdb')
233231
cm('pydoc', ignore=('input', 'output',)) # properties

Lib/test/test_sunau.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ class SunauULAWTest(SunauTest, unittest.TestCase):
119119
frames = byteswap(frames, 2)
120120

121121

122-
class SunauMiscTests(audiotests.AudioMiscTests, unittest.TestCase):
123-
module = sunau
124-
125-
126122
class SunauLowLevelTest(unittest.TestCase):
127123

128124
def test_read_bad_magic_number(self):

Lib/test/test_wave.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ class WavePCM32Test(WaveTest, unittest.TestCase):
105105
frames = byteswap(frames, 4)
106106

107107

108-
class MiscTestCase(audiotests.AudioMiscTests, unittest.TestCase):
109-
module = wave
110-
108+
class MiscTestCase(unittest.TestCase):
111109
def test__all__(self):
112110
blacklist = {'WAVE_FORMAT_PCM'}
113111
support.check__all__(self, wave, blacklist=blacklist)

Lib/wave.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,15 @@
7171
is destroyed.
7272
"""
7373

74+
from chunk import Chunk
75+
from collections import namedtuple
76+
import audioop
7477
import builtins
78+
import struct
79+
import sys
80+
7581

76-
__all__ = ["open", "openfp", "Error", "Wave_read", "Wave_write"]
82+
__all__ = ["open", "Error", "Wave_read", "Wave_write"]
7783

7884
class Error(Exception):
7985
pass
@@ -82,13 +88,6 @@ class Error(Exception):
8288

8389
_array_fmts = None, 'b', 'h', None, 'i'
8490

85-
import audioop
86-
import struct
87-
import sys
88-
from chunk import Chunk
89-
from collections import namedtuple
90-
import warnings
91-
9291
_wave_params = namedtuple('_wave_params',
9392
'nchannels sampwidth framerate nframes comptype compname')
9493

@@ -512,8 +511,3 @@ def open(f, mode=None):
512511
return Wave_write(f)
513512
else:
514513
raise Error("mode must be 'r', 'rb', 'w', or 'wb'")
515-
516-
def openfp(f, mode=None):
517-
warnings.warn("wave.openfp is deprecated since Python 3.7. "
518-
"Use wave.open instead.", DeprecationWarning, stacklevel=2)
519-
return open(f, mode=mode)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``aifc.openfp()`` alias to ``aifc.open()``, ``sunau.openfp()`` alias to
2+
``sunau.open()``, and ``wave.openfp()`` alias to ``wave.open()`` have been
3+
removed. They were deprecated since Python 3.7.

0 commit comments

Comments
 (0)