Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Building C and C++ Extensions on Windows" documentation shows 2.x way of initializing module #54982

Closed
thorstenbehrens mannequin opened this issue Dec 26, 2010 · 2 comments
Labels
docs Documentation in the Doc dir

Comments

@thorstenbehrens
Copy link
Mannequin

thorstenbehrens mannequin commented Dec 26, 2010

BPO 10773
Nosy @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2010-12-28.09:30:50.547>
created_at = <Date 2010-12-26.17:27:42.488>
labels = ['docs']
title = '"Building C and C++ Extensions on Windows" documentation shows 2.x way of initializing module'
updated_at = <Date 2010-12-28.09:30:50.545>
user = 'https://bugs.python.org/thorstenbehrens'

bugs.python.org fields:

activity = <Date 2010-12-28.09:30:50.545>
actor = 'georg.brandl'
assignee = 'docs@python'
closed = True
closed_date = <Date 2010-12-28.09:30:50.547>
closer = 'georg.brandl'
components = ['Documentation']
creation = <Date 2010-12-26.17:27:42.488>
creator = 'thorsten.behrens'
dependencies = []
files = []
hgrepos = []
issue_num = 10773
keywords = []
message_count = 2.0
messages = ['124667', '124771']
nosy_count = 3.0
nosy_names = ['georg.brandl', 'docs@python', 'thorsten.behrens']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue10773'
versions = ['Python 3.1']

@thorstenbehrens
Copy link
Mannequin Author

thorstenbehrens mannequin commented Dec 26, 2010

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;

>

@thorstenbehrens thorstenbehrens mannequin added the docs Documentation in the Doc dir label Dec 26, 2010
@birkenfeld
Copy link
Member

Thanks, fixed in r87524.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

1 participant