classification
Title: "Building C and C++ Extensions on Windows" documentation shows 2.x way of initializing module
Type: Stage:
Components: Documentation Versions: Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, georg.brandl, thorsten.behrens
Priority: normal Keywords:

Created on 2010-12-26 17:27 by thorsten.behrens, last changed 2010-12-28 09:30 by georg.brandl. This issue is now closed.

Messages (2)
msg124667 - (view) Author: Thorsten Behrens (thorsten.behrens) Date: 2010-12-26 17:27
The documentation titled "Building C and C++ Extensions on Windows" at http://docs.python.org/py3k/extending/windows.html shows a Python 2.x way of handling static type object initializers, to whit:

>>
If your module creates a new type, you may have trouble with this line:

PyVarObject_HEAD_INIT(&PyType_Type, 0)

Static type object initializers in extension modules may cause compiles to fail with an error message like “initializer not a constant”. This shows up when building DLL under MSVC. Change it to:

PyVarObject_HEAD_INIT(NULL, 0)

and add the following to the module initialization function:

MyObject_Type.ob_type = &PyType_Type;

>>

That last line will not function in Python 3.x. However, PyType_Ready will fill in the ob_type field if it is empty, if I understand PyType_Ready correctly. Therefore, the last few lines of this documentation snippet can become:

>>
and add the following to the module initialization function:

if (PyType_Ready(&MyObject_Type) < 0)
    return NULL;
>>
msg124771 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-12-28 09:30
Thanks, fixed in r87524.
History
Date User Action Args
2010-12-28 09:30:50georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg124771

resolution: fixed
2010-12-26 17:27:42thorsten.behrenscreate