Re: PEP 489: Multi-phase extension module initialization; version 6

Stefan Behnel <[email protected]> Thu, 21 May 2015 08:06:37 +0200
Newsgroups gmane.comp.python.import
Message-ID <[email protected]>
Petr Viktorin schrieb am 20.05.2015 um 13:34:
> To prevent crashes when the module is loaded in older versions of Python,
> the PyModuleDef object must be initialized using the newly added
> PyModuleDef_Init function. This sets the object type (which cannot be done
> statically on certain compilers), refcount, and internal bookkeeping data
> (m_index).
> For example, an extension module "example" would be exported as::
> 
>     static PyModuleDef example_def = {...}
> 
>     PyMODINIT_FUNC
>     PyInit_example(void)
>     {
>         return PyModuleDef_Init(&example_def);
>     }

If PyModuleDef_Init() is really a function, this will not help with "older
versions of Python", which do not have the function available. So, is it
going to be a macro?

Stefan