[Import-SIG] PEP 489: Multi-phase extension module initialization; version 6

Stefan Behnel stefan_ml at behnel.de
Thu May 21 08:06:37 CEST 2015

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 = {...}
>     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?


More information about the Import-SIG mailing list