History

ext/aubiomodule.c: prepare for python 3, see #33

Paul Brossier committed 10 years ago

Commit 2e4ae1d1 parent 4041a6d1 file · +40 −5Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/ext/aubiomodule.c+40−5
@@ -248,10 +248,25 @@ static PyMethodDef aubio_methods[] = { · 247 unmodified lines
248 {NULL, NULL} /* Sentinel */248 {NULL, NULL} /* Sentinel */
249};249};
250 250
251PyMODINIT_FUNC251#if PY_MAJOR_VERSION >= 3
252init_aubio (void)252// Python3 module definition
253static struct PyModuleDef moduledef = {
254 PyModuleDef_HEAD_INIT,
255 "_aubio", /* m_name */
256 aubio_module_doc, /* m_doc */
257 -1, /* m_size */
258 aubio_methods, /* m_methods */
259 NULL, /* m_reload */
260 NULL, /* m_traverse */
261 NULL, /* m_clear */
262 NULL, /* m_free */
263};
264#endif
265
266static PyObject *
267initaubio (void)
253{268{
254 PyObject *m;269 PyObject *m = NULL;
255 int err;270 int err;
256 271
257 // fvec is defined in __init__.py272 // fvec is defined in __init__.py
@@ -265,13 +280,17 @@ init_aubio (void) · 7 unmodified lines
265 // generated objects280 // generated objects
266 || (generated_types_ready() < 0 )281 || (generated_types_ready() < 0 )
267 ) {282 ) {
268 return;283 return m;
269 }284 }
270 285
286#if PY_MAJOR_VERSION >= 3
287 m = PyModule_Create(&moduledef);
288#else
271 m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc);289 m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc);
290#endif
272 291
273 if (m == NULL) {292 if (m == NULL) {
274 return;293 return m;
275 }294 }
276 295
277 err = _import_array ();296 err = _import_array ();
@@ -300,4 +319,20 @@ init_aubio (void) · 22 unmodified lines
300 319
301 // add ufunc320 // add ufunc
302 add_ufuncs(m);321 add_ufuncs(m);
322
323 return m;
303}324}
325
326#if PY_MAJOR_VERSION >= 3
327 // Python3 init
328 PyMODINIT_FUNC PyInit__aubio(void)
329 {
330 return initaubio();
331 }
332#else
333 // Python 2 init
334 PyMODINIT_FUNC init_aubio(void)
335 {
336 initaubio();
337 }
338#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t