The second bit is the definition of the type object. ::
static PyTypeObject CustomType = {
- PyVarObject_HEAD_INIT(NULL, 0)
+ .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "custom.Custom",
.tp_doc = PyDoc_STR("Custom objects"),
.tp_basicsize = sizeof(CustomObject),
We're going to pick it apart, one field at a time::
- PyVarObject_HEAD_INIT(NULL, 0)
+ .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
This line is mandatory boilerplate to initialize the ``ob_base``
field mentioned above. ::
} CustomObject;
static PyTypeObject CustomType = {
- PyVarObject_HEAD_INIT(NULL, 0)
+ .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "custom.Custom",
.tp_doc = PyDoc_STR("Custom objects"),
.tp_basicsize = sizeof(CustomObject),
};
static PyModuleDef custommodule = {
- PyModuleDef_HEAD_INIT,
+ .m_base = PyModuleDef_HEAD_INIT,
.m_name = "custom",
.m_doc = "Example module that creates an extension type.",
.m_size = -1,
};
static PyTypeObject CustomType = {
- PyVarObject_HEAD_INIT(NULL, 0)
+ .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "custom2.Custom",
.tp_doc = PyDoc_STR("Custom objects"),
.tp_basicsize = sizeof(CustomObject),
};
static PyModuleDef custommodule = {
- PyModuleDef_HEAD_INIT,
+ .m_base =PyModuleDef_HEAD_INIT,
.m_name = "custom2",
.m_doc = "Example module that creates an extension type.",
.m_size = -1,
};
static PyTypeObject CustomType = {
- PyVarObject_HEAD_INIT(NULL, 0)
+ .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "custom3.Custom",
.tp_doc = PyDoc_STR("Custom objects"),
.tp_basicsize = sizeof(CustomObject),
};
static PyModuleDef custommodule = {
- PyModuleDef_HEAD_INIT,
+ .m_base = PyModuleDef_HEAD_INIT,
.m_name = "custom3",
.m_doc = "Example module that creates an extension type.",
.m_size = -1,
};
static PyTypeObject CustomType = {
- PyVarObject_HEAD_INIT(NULL, 0)
+ .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "custom4.Custom",
.tp_doc = PyDoc_STR("Custom objects"),
.tp_basicsize = sizeof(CustomObject),
};
static PyModuleDef custommodule = {
- PyModuleDef_HEAD_INIT,
+ .m_base = PyModuleDef_HEAD_INIT,
.m_name = "custom4",
.m_doc = "Example module that creates an extension type.",
.m_size = -1,
--- /dev/null
+Fix extension type from documentation for compiling in C++20 mode