Skip to content

Commit 74949fa

Browse files
author
brett.cannon
committed
Deprecate the audiodev module for 3.0.
git-svn-id: http://svn.python.org/projects/python/trunk@62793 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent a8cf5f5 commit 74949fa

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

Doc/library/undoc.rst

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Multimedia
4747
:mod:`audiodev`
4848
--- Platform-independent API for playing audio data.
4949

50+
.. warning:: The :mod:`audiodev` module has been removed in 3.0.
51+
5052
:mod:`linuxaudiodev`
5153
--- Play audio data on the Linux audio device. Replaced in Python 2.3 by the
5254
:mod:`ossaudiodev` module.

Lib/audiodev.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"""Classes for manipulating audio devices (currently only for Sun and SGI)"""
2+
from warnings import warnpy3k
3+
warnpy3k("the audiodev module has been removed in Python 3.0", stacklevel=2)
4+
del warnpy3k
25

36
__all__ = ["error","AudioDev"]
47

Lib/test/test_py3kwarn.py

+35-1
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,42 @@ def test_buffer(self):
124124
self.assertWarning(buffer('a'), w, expected)
125125

126126

127+
class TestStdlibRemovals(unittest.TestCase):
128+
129+
all_platforms = ('audiodev',)
130+
131+
def check_removal(self, module_name):
132+
"""Make sure the specified module, when imported, raises a
133+
DeprecationWarning and specifies itself in the message."""
134+
original_module = None
135+
if module_name in sys.modules:
136+
original_module = sys.modules[module_name]
137+
del sys.modules[module_name]
138+
try:
139+
with catch_warning() as w:
140+
warnings.filterwarnings("error", ".+ removed",
141+
DeprecationWarning)
142+
try:
143+
__import__(module_name, level=0)
144+
except DeprecationWarning as exc:
145+
self.assert_(module_name in exc.args[0])
146+
else:
147+
self.fail("DeprecationWarning not raised for %s" %
148+
module_name)
149+
finally:
150+
if original_module:
151+
sys.modules[module_name] = original_module
152+
153+
154+
def test_platform_independent_removals(self):
155+
# Make sure that the modules that are available on all platforms raise
156+
# the proper DeprecationWarning.
157+
for module_name in self.all_platforms:
158+
self.check_removal(module_name)
159+
160+
127161
def test_main():
128-
run_unittest(TestPy3KWarnings)
162+
run_unittest(TestPy3KWarnings, TestStdlibRemovals)
129163

130164
if __name__ == '__main__':
131165
test_main()

0 commit comments

Comments
 (0)