mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Use the portable form of initializing the ob_type field for new types.
This commit is contained in:
parent
71ddcd87e2
commit
6724835959
1 changed files with 8 additions and 2 deletions
|
@ -132,8 +132,10 @@ Xxo_setattr(self, name, v)
|
|||
return PyDict_SetItemString(self->x_attr, name, v);
|
||||
}
|
||||
|
||||
staticforward PyTypeObject Xxo_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
statichere PyTypeObject Xxo_Type = {
|
||||
/* The ob_type field must be initialized in the module init function
|
||||
* to be portable to Windows without using C++. */
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"Xxo", /*tp_name*/
|
||||
sizeof(XxoObject), /*tp_basicsize*/
|
||||
|
@ -242,6 +244,10 @@ initxx()
|
|||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
/* Initialize the type of the new type object here; doing it here
|
||||
* is required for portability to Windows without requiring C++. */
|
||||
Xxo_Type.ob_type = &PyType_Type;
|
||||
|
||||
/* Create the module and add the functions */
|
||||
m = Py_InitModule("xx", xx_methods);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue