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

Skip to content

gh-99202: Fix extension type from documentation for compiling in C++20 mode #102518

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

Merged
merged 8 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Doc/extending/newtypes_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ standard Python floats::
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),
Expand All @@ -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::

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. ::
Expand Down
4 changes: 2 additions & 2 deletions Doc/includes/custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ typedef struct {
} 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),
Expand All @@ -17,7 +17,7 @@ static PyTypeObject CustomType = {
};

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,
Expand Down
4 changes: 2 additions & 2 deletions Doc/includes/custom2.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static PyMethodDef Custom_methods[] = {
};

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),
Expand All @@ -104,7 +104,7 @@ static PyTypeObject CustomType = {
};

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,
Expand Down
4 changes: 2 additions & 2 deletions Doc/includes/custom3.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static PyMethodDef Custom_methods[] = {
};

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),
Expand All @@ -145,7 +145,7 @@ static PyTypeObject CustomType = {
};

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,
Expand Down
4 changes: 2 additions & 2 deletions Doc/includes/custom4.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static PyMethodDef Custom_methods[] = {
};

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),
Expand All @@ -163,7 +163,7 @@ static PyTypeObject CustomType = {
};

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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix extension type from documentation for compiling in C++20 mode