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

Stefan Behnel stefan_ml at behnel.de
Thu May 21 08:22:27 CEST 2015


Stefan Behnel schrieb am 21.05.2015 um 08:06:
> 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?

Ah, ok, I found it further down in the PEP. It's not actually supposed to
be called in older Python versions, right? Meaning, we only provide source
level backwards compatibility and not binary backwards compatibility for
extension modules?

Then the paragraph above is really misleading.

Stefan




More information about the Import-SIG mailing list