Commit ec12e829 authored by Georg Brandl's avatar Georg Brandl

#5360: replace PyObject_HEAD_INIT by PyVarObject_HEAD_INIT.

parent f341acd5
...@@ -72,7 +72,7 @@ Python floats:: ...@@ -72,7 +72,7 @@ Python floats::
Moving on, we come to the crunch --- the type object. :: Moving on, we come to the crunch --- the type object. ::
static PyTypeObject noddy_NoddyType = { static PyTypeObject noddy_NoddyType = {
PyObject_HEAD_INIT(NULL) PyVarObject_HEAD_INIT(NULL, 0)
"noddy.Noddy", /* tp_name */ "noddy.Noddy", /* tp_name */
sizeof(noddy_NoddyObject), /* tp_basicsize */ sizeof(noddy_NoddyObject), /* tp_basicsize */
0, /* tp_itemsize */ 0, /* tp_itemsize */
...@@ -103,11 +103,11 @@ it's common practice to not specify them explicitly unless you need them. ...@@ -103,11 +103,11 @@ it's common practice to not specify them explicitly unless you need them.
This is so important that we're going to pick the top of it apart still This is so important that we're going to pick the top of it apart still
further:: further::
PyObject_HEAD_INIT(NULL) PyVarObject_HEAD_INIT(NULL, 0)
This line is a bit of a wart; what we'd like to write is:: This line is a bit of a wart; what we'd like to write is::
PyObject_HEAD_INIT(&PyType_Type) PyVarObject_HEAD_INIT(&PyType_Type, 0)
as the type of a type object is "type", but this isn't strictly conforming C and as the type of a type object is "type", but this isn't strictly conforming C and
some compilers complain. Fortunately, this member will be filled in for us by some compilers complain. Fortunately, this member will be filled in for us by
...@@ -1427,7 +1427,7 @@ type is defined with the following structure:: ...@@ -1427,7 +1427,7 @@ type is defined with the following structure::
The statically-declared type object for instances is defined this way:: The statically-declared type object for instances is defined this way::
PyTypeObject PyInstance_Type = { PyTypeObject PyInstance_Type = {
PyObject_HEAD_INIT(&PyType_Type) PyVarObject_HEAD_INIT(&PyType_Type, 0)
0, 0,
"module.instance", "module.instance",
......
...@@ -169,11 +169,11 @@ described here are distributed with the Python sources in the ...@@ -169,11 +169,11 @@ described here are distributed with the Python sources in the
If your module creates a new type, you may have trouble with this line:: If your module creates a new type, you may have trouble with this line::
PyObject_HEAD_INIT(&PyType_Type) PyVarObject_HEAD_INIT(&PyType_Type, 0)
Change it to:: Change it to::
PyObject_HEAD_INIT(NULL) PyVarObject_HEAD_INIT(NULL, 0)
and add the following to the module initialization function:: and add the following to the module initialization function::
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment