]> granicus.if.org Git - python/commitdiff
Deprecate the sunaudio module for removal in Python 3.0. The sunau module can provide...
authorBrett Cannon <bcannon@gmail.com>
Fri, 18 Jul 2008 19:30:22 +0000 (19:30 +0000)
committerBrett Cannon <bcannon@gmail.com>
Fri, 18 Jul 2008 19:30:22 +0000 (19:30 +0000)
Doc/library/undoc.rst
Lib/sunaudio.py
Lib/test/test_ossaudiodev.py
Lib/test/test_py3kwarn.py
Misc/NEWS

index a1b4b259d041a5eab4a79ffa366ed7d860ce08f9..09c61d267c824aa3163eaea3ffd5a9dbef5f1f64 100644 (file)
@@ -60,6 +60,8 @@ Multimedia
 :mod:`sunaudio`
    --- Interpret Sun audio headers (may become obsolete or a tool/demo).
 
+   .. warning:: The :mod:`sunaudio` module has been removed in Python 3.0.
+
 :mod:`toaiff`
    --- Convert "arbitrary" sound files to AIFF files; should probably become a tool
    or demo.  Requires the external program :program:`sox`.
index 3b0ee2793c126b1008a0cd960f9e459937166d0a..97d7332c4856ac9b0ba2f0a63c8f6ea68f9620d8 100644 (file)
@@ -1,4 +1,9 @@
 """Interpret sun audio headers."""
+from warnings import warnpy3k
+warnpy3k("the sunaudio module has been removed in Python 3.0; "
+         "use the sunau module instead", stacklevel=2)
+del warnpy3k
+
 
 MAGIC = '.snd'
 
index f2ce67bad796ed8c0d6aa80a0413385d045b78ba..eb4dd028905b614a956fd205898ae1dafb151e9b 100644 (file)
@@ -6,7 +6,7 @@ from test.test_support import findfile, TestSkipped
 import errno
 import ossaudiodev
 import sys
-import sunaudio
+import sunau
 import time
 import audioop
 import unittest
@@ -22,15 +22,16 @@ except ImportError:
         AFMT_S16_NE = ossaudiodev.AFMT_S16_BE
 
 
-SND_FORMAT_MULAW_8 = 1
-
 def read_sound_file(path):
-    fp = open(path, 'rb')
-    size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
-    data = fp.read()
-    fp.close()
-
-    if enc != SND_FORMAT_MULAW_8:
+    with open(path, 'rb') as fp:
+        au = sunau.open(fp)
+        rate = au.getframerate()
+        nchannels = au.getnchannels()
+        encoding = au._encoding
+        fp.seek(0)
+        data = fp.read()
+
+    if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
         raise RuntimeError("Expect .au file with 8-bit mu-law samples")
 
     # Convert the data to 16-bit signed.
index 0ddc979634694326100300aa2eeb659cd80fff13..67b2538f01a502d50b2f9bc78a6ae2da3cfd27a7 100644 (file)
@@ -173,8 +173,9 @@ class TestStdlibRemovals(unittest.TestCase):
     # test.testall not tested as it executes all unit tests as an
     # import side-effect.
     all_platforms = ('audiodev', 'imputil', 'mutex', 'user', 'new', 'rexec',
-                        'Bastion', 'compiler', 'dircache', 'mimetools', 'fpformat',
-                        'ihooks', 'mhlib', 'statvfs', 'htmllib', 'sgmllib', 'rfc822')
+                        'Bastion', 'compiler', 'dircache', 'mimetools',
+                        'fpformat', 'ihooks', 'mhlib', 'statvfs', 'htmllib',
+                        'sgmllib', 'rfc822', 'sunaudio')
     inclusive_platforms = {'irix' : ('pure', 'AL', 'al', 'CD', 'cd', 'cddb',
                                      'cdplayer', 'CL', 'cl', 'DEVICE', 'GL',
                                      'gl', 'ERRNO', 'FILE', 'FL', 'flp', 'fl',
index 853df55fc6ac71bcea0eb340a8ab52b348db9e8c..1ec76951435334ab29db15d5cce8e8975225e6ff 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -70,6 +70,8 @@ Library
 - Issue #3389: Allow resolving dotted names for handlers in logging
   configuration files.
 
+- Deprecate the sunaudio module for removal in Python 3.0.
+
 - Issue #3395: fix reference in test_multiprocessing to old debugInfo method
 
 - Issue #3312: Fix two crashes in sqlite3.