mirror of https://github.com/python/cpython
gh-99202: Fix extension type from documentation for compiling in C++20 mode (#102518)
This commit is contained in:
parent
52bc2e7b9d
commit
23cf1e20a6
|
@ -88,7 +88,7 @@ standard Python floats::
|
||||||
The second bit is the definition of the type object. ::
|
The second bit is the definition of the type object. ::
|
||||||
|
|
||||||
static PyTypeObject CustomType = {
|
static PyTypeObject CustomType = {
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
.tp_name = "custom.Custom",
|
.tp_name = "custom.Custom",
|
||||||
.tp_doc = PyDoc_STR("Custom objects"),
|
.tp_doc = PyDoc_STR("Custom objects"),
|
||||||
.tp_basicsize = sizeof(CustomObject),
|
.tp_basicsize = sizeof(CustomObject),
|
||||||
|
@ -109,7 +109,7 @@ common practice to not specify them explicitly unless you need them.
|
||||||
|
|
||||||
We're going to pick it apart, one field at a time::
|
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``
|
This line is mandatory boilerplate to initialize the ``ob_base``
|
||||||
field mentioned above. ::
|
field mentioned above. ::
|
||||||
|
|
|
@ -7,7 +7,7 @@ typedef struct {
|
||||||
} CustomObject;
|
} CustomObject;
|
||||||
|
|
||||||
static PyTypeObject CustomType = {
|
static PyTypeObject CustomType = {
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
.tp_name = "custom.Custom",
|
.tp_name = "custom.Custom",
|
||||||
.tp_doc = PyDoc_STR("Custom objects"),
|
.tp_doc = PyDoc_STR("Custom objects"),
|
||||||
.tp_basicsize = sizeof(CustomObject),
|
.tp_basicsize = sizeof(CustomObject),
|
||||||
|
@ -17,7 +17,7 @@ static PyTypeObject CustomType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyModuleDef custommodule = {
|
static PyModuleDef custommodule = {
|
||||||
PyModuleDef_HEAD_INIT,
|
.m_base = PyModuleDef_HEAD_INIT,
|
||||||
.m_name = "custom",
|
.m_name = "custom",
|
||||||
.m_doc = "Example module that creates an extension type.",
|
.m_doc = "Example module that creates an extension type.",
|
||||||
.m_size = -1,
|
.m_size = -1,
|
||||||
|
|
|
@ -90,7 +90,7 @@ static PyMethodDef Custom_methods[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyTypeObject CustomType = {
|
static PyTypeObject CustomType = {
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
.tp_name = "custom2.Custom",
|
.tp_name = "custom2.Custom",
|
||||||
.tp_doc = PyDoc_STR("Custom objects"),
|
.tp_doc = PyDoc_STR("Custom objects"),
|
||||||
.tp_basicsize = sizeof(CustomObject),
|
.tp_basicsize = sizeof(CustomObject),
|
||||||
|
@ -104,7 +104,7 @@ static PyTypeObject CustomType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyModuleDef custommodule = {
|
static PyModuleDef custommodule = {
|
||||||
PyModuleDef_HEAD_INIT,
|
.m_base =PyModuleDef_HEAD_INIT,
|
||||||
.m_name = "custom2",
|
.m_name = "custom2",
|
||||||
.m_doc = "Example module that creates an extension type.",
|
.m_doc = "Example module that creates an extension type.",
|
||||||
.m_size = -1,
|
.m_size = -1,
|
||||||
|
|
|
@ -130,7 +130,7 @@ static PyMethodDef Custom_methods[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyTypeObject CustomType = {
|
static PyTypeObject CustomType = {
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
.tp_name = "custom3.Custom",
|
.tp_name = "custom3.Custom",
|
||||||
.tp_doc = PyDoc_STR("Custom objects"),
|
.tp_doc = PyDoc_STR("Custom objects"),
|
||||||
.tp_basicsize = sizeof(CustomObject),
|
.tp_basicsize = sizeof(CustomObject),
|
||||||
|
@ -145,7 +145,7 @@ static PyTypeObject CustomType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyModuleDef custommodule = {
|
static PyModuleDef custommodule = {
|
||||||
PyModuleDef_HEAD_INIT,
|
.m_base = PyModuleDef_HEAD_INIT,
|
||||||
.m_name = "custom3",
|
.m_name = "custom3",
|
||||||
.m_doc = "Example module that creates an extension type.",
|
.m_doc = "Example module that creates an extension type.",
|
||||||
.m_size = -1,
|
.m_size = -1,
|
||||||
|
|
|
@ -146,7 +146,7 @@ static PyMethodDef Custom_methods[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyTypeObject CustomType = {
|
static PyTypeObject CustomType = {
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
.ob_base = PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
.tp_name = "custom4.Custom",
|
.tp_name = "custom4.Custom",
|
||||||
.tp_doc = PyDoc_STR("Custom objects"),
|
.tp_doc = PyDoc_STR("Custom objects"),
|
||||||
.tp_basicsize = sizeof(CustomObject),
|
.tp_basicsize = sizeof(CustomObject),
|
||||||
|
@ -163,7 +163,7 @@ static PyTypeObject CustomType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyModuleDef custommodule = {
|
static PyModuleDef custommodule = {
|
||||||
PyModuleDef_HEAD_INIT,
|
.m_base = PyModuleDef_HEAD_INIT,
|
||||||
.m_name = "custom4",
|
.m_name = "custom4",
|
||||||
.m_doc = "Example module that creates an extension type.",
|
.m_doc = "Example module that creates an extension type.",
|
||||||
.m_size = -1,
|
.m_size = -1,
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix extension type from documentation for compiling in C++20 mode
|
Loading…
Reference in New Issue