From: Antoine Pitrou Date: Tue, 23 Mar 2010 00:25:54 +0000 (+0000) Subject: Issue #8139: ossaudiodev didn't initialize its types properly, therefore X-Git-Tag: v3.2a1~1339 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39b3543174b53f907e629df830b192aa77455740;p=python Issue #8139: ossaudiodev didn't initialize its types properly, therefore some methods (such as oss_mixer_device.fileno()) were not available. Initial patch by Bertrand Janin. --- diff --git a/Lib/test/test_ossaudiodev.py b/Lib/test/test_ossaudiodev.py index dda6137d19..055ad6c167 100644 --- a/Lib/test/test_ossaudiodev.py +++ b/Lib/test/test_ossaudiodev.py @@ -159,6 +159,15 @@ class OSSAudioDevTests(unittest.TestCase): dsp.close() self.assertTrue(dsp.closed) + def test_mixer_methods(self): + # Issue #8139: ossaudiodev didn't initialize its types properly, + # therefore some methods were unavailable. + mixer = ossaudiodev.openmixer() + try: + self.assertGreaterEqual(mixer.fileno(), 0) + finally: + mixer.close() + def test_main(): try: diff --git a/Misc/ACKS b/Misc/ACKS index 2f47dbb317..651e6e8f99 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -372,6 +372,7 @@ Ben Jackson David Jacobs Kevin Jacobs Kjetil Jacobsen +Bertrand Janin Geert Jansen Jack Jansen Bill Janssen diff --git a/Misc/NEWS b/Misc/NEWS index 86eda39a61..0d316a0bcb 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -287,6 +287,10 @@ C-API Library ------- +- Issue #8139: ossaudiodev didn't initialize its types properly, therefore + some methods (such as oss_mixer_device.fileno()) were not available. + Initial patch by Bertrand Janin. + - Issue #7512: shutil.copystat() could raise an OSError when the filesystem didn't support chflags() (for example ZFS under FreeBSD). The error is now silenced. diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c index 7686902bb5..6654d712e5 100644 --- a/Modules/ossaudiodev.c +++ b/Modules/ossaudiodev.c @@ -986,11 +986,17 @@ static struct PyModuleDef ossaudiodevmodule = { NULL }; -PyObject* +PyMODINIT_FUNC PyInit_ossaudiodev(void) { PyObject *m; + if (PyType_Ready(&OSSAudioType) < 0) + return NULL; + + if (PyType_Ready(&OSSMixerType) < 0) + return NULL; + m = PyModule_Create(&ossaudiodevmodule); if (m == NULL) return NULL;