Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6724835

Browse files
committed
Use the portable form of initializing the ob_type field for new types.
1 parent 71ddcd8 commit 6724835

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Modules/xxmodule.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ Xxo_setattr(self, name, v)
132132
return PyDict_SetItemString(self->x_attr, name, v);
133133
}
134134

135-
staticforward PyTypeObject Xxo_Type = {
136-
PyObject_HEAD_INIT(&PyType_Type)
135+
statichere PyTypeObject Xxo_Type = {
136+
/* The ob_type field must be initialized in the module init function
137+
* to be portable to Windows without using C++. */
138+
PyObject_HEAD_INIT(NULL)
137139
0, /*ob_size*/
138140
"Xxo", /*tp_name*/
139141
sizeof(XxoObject), /*tp_basicsize*/
@@ -242,6 +244,10 @@ initxx()
242244
{
243245
PyObject *m, *d;
244246

247+
/* Initialize the type of the new type object here; doing it here
248+
* is required for portability to Windows without requiring C++. */
249+
Xxo_Type.ob_type = &PyType_Type;
250+
245251
/* Create the module and add the functions */
246252
m = Py_InitModule("xx", xx_methods);
247253

0 commit comments

Comments
 (0)