Ignore:
Timestamp:
Apr 18, 2016, 10:52:00 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
5c1200a
Parents:
4041a6d
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/ext/aubiomodule.c

    r4041a6d r2e4ae1d  
    249249};
    250250
    251 PyMODINIT_FUNC
    252 init_aubio (void)
    253 {
    254   PyObject *m;
     251#if PY_MAJOR_VERSION >= 3
     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)
     268{
     269  PyObject *m = NULL;
    255270  int err;
    256271
     
    266281      || (generated_types_ready() < 0 )
    267282  ) {
    268     return;
    269   }
    270 
     283    return m;
     284  }
     285
     286#if PY_MAJOR_VERSION >= 3
     287  m = PyModule_Create(&moduledef);
     288#else
    271289  m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc);
     290#endif
    272291
    273292  if (m == NULL) {
    274     return;
     293    return m;
    275294  }
    276295
     
    301320  // add ufunc
    302321  add_ufuncs(m);
    303 }
     322
     323  return m;
     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
Note: See TracChangeset for help on using the changeset viewer.