]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-99202: Fix extension type from documentation for compiling in C++20 mode (#102518)
authorJeffrey Newman <jeff@newman.me>
Thu, 6 Apr 2023 15:59:36 +0000 (10:59 -0500)
committerGitHub <noreply@github.com>
Thu, 6 Apr 2023 15:59:36 +0000 (17:59 +0200)
Doc/extending/newtypes_tutorial.rst
Doc/includes/custom.c
Doc/includes/custom2.c
Doc/includes/custom3.c
Doc/includes/custom4.c
Misc/NEWS.d/next/Documentation/2023-03-07-23-30-29.gh-issue-99202.hhiAJF.rst [new file with mode: 0644]

index 54de3fd42437d94cc3c8ed23fe40bbc32827713d..f89934a11f12a8d40f52ad4594758d4bae562844 100644 (file)
@@ -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),
@@ -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. ::
index 26ca754964733d0d9180baded60b28f2861ea6d5..9cfba50ace25dbfde28c97f3fb4e499f7001074e 100644 (file)
@@ -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),
@@ -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,
index a3b2d6ab78d3c4921743e2177ea8f2b9f1f44c3d..a0222b1795209b78b6d5d3af53675021d3a80dbd 100644 (file)
@@ -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),
@@ -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,
index 1a68bc4be8c39916cfdae8ea370295f6bde31c2c..4aeebe0a7507d10d30a6cecf8d65418a9e6129ae 100644 (file)
@@ -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),
@@ -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,
index b932d159d26e93e92e80b849bf05a06550706d01..3998918f68301e9b54e1c873663dee2af07d0c7c 100644 (file)
@@ -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),
@@ -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,
diff --git a/Misc/NEWS.d/next/Documentation/2023-03-07-23-30-29.gh-issue-99202.hhiAJF.rst b/Misc/NEWS.d/next/Documentation/2023-03-07-23-30-29.gh-issue-99202.hhiAJF.rst
new file mode 100644 (file)
index 0000000..1569e81
--- /dev/null
@@ -0,0 +1 @@
+Fix extension type from documentation for compiling in C++20 mode