Generalize type object initialization to work with both Python 2.* and Python 3.*
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 15 Oct 2009 19:14:57 +0000 (15:14 -0400)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 19 Oct 2009 08:02:13 +0000 (11:02 +0300)
The layout of PyVarObject changed between python 2 and python 3, and this leads
to the existing code for all of the various PyTypeObject initializers failing to
compile with python 3

Change the way we initialize these structs to use PyVarObject_HEAD_INIT directly,
rather than merely PyObject_HEAD_INIT, so that it compiles cleanly with both major
versions of Python

python/header-py.c
python/rpmds-py.c
python/rpmfd-py.c
python/rpmfi-py.c
python/rpmkeyring-py.c
python/rpmmi-py.c
python/rpmps-py.c
python/rpmtd-py.c
python/rpmte-py.c
python/rpmts-py.c
python/spec-py.c

index 18a7e66..3c2f394 100644 (file)
@@ -502,8 +502,7 @@ static char hdr_doc[] =
 "";
 
 PyTypeObject hdr_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.hdr",                      /* tp_name */
        sizeof(hdrObject),              /* tp_size */
        0,                              /* tp_itemsize */
index 8938cc7..f45c908 100644 (file)
@@ -452,8 +452,7 @@ static char rpmds_doc[] =
 "";
 
 PyTypeObject rpmds_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.ds",                       /* tp_name */
        sizeof(rpmdsObject),            /* tp_basicsize */
        0,                              /* tp_itemsize */
index 193d8e8..62ddeb0 100644 (file)
@@ -285,8 +285,7 @@ static PyGetSetDef rpmfd_getseters[] = {
 };
 
 PyTypeObject rpmfd_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.fd",                       /* tp_name */
        sizeof(rpmfdObject),            /* tp_size */
        0,                              /* tp_itemsize */
index 5484a1b..c6d2ba4 100644 (file)
@@ -316,8 +316,7 @@ static char rpmfi_doc[] =
 "";
 
 PyTypeObject rpmfi_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.fi",                       /* tp_name */
        sizeof(rpmfiObject),            /* tp_basicsize */
        0,                              /* tp_itemsize */
index 00be981..6bb27af 100644 (file)
@@ -51,8 +51,7 @@ static struct PyMethodDef rpmPubkey_methods[] = {
 static char rpmPubkey_doc[] = "";
 
 PyTypeObject rpmPubkey_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.pubkey",                   /* tp_name */
        sizeof(rpmPubkeyObject),        /* tp_size */
        0,                              /* tp_itemsize */
@@ -133,8 +132,7 @@ static char rpmKeyring_doc[] =
 "";
 
 PyTypeObject rpmKeyring_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.keyring",                  /* tp_name */
        sizeof(rpmKeyringObject),       /* tp_size */
        0,                              /* tp_itemsize */
index 0a87153..f6dd802 100644 (file)
@@ -146,8 +146,7 @@ static char rpmmi_doc[] =
 "";
 
 PyTypeObject rpmmi_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.mi",                       /* tp_name */
        sizeof(rpmmiObject),            /* tp_size */
        0,                              /* tp_itemsize */
index 1b08e2f..ccea5d2 100644 (file)
@@ -74,8 +74,7 @@ static PyObject *rpmprob_str(rpmProblemObject *s)
 }
 
 PyTypeObject rpmProblem_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.prob",                     /* tp_name */
        sizeof(rpmProblemObject),               /* tp_basicsize */
        0,                              /* tp_itemsize */
@@ -230,8 +229,7 @@ static char rpmps_doc[] =
 "";
 
 PyTypeObject rpmps_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.ps",                       /* tp_name */
        sizeof(rpmpsObject),            /* tp_basicsize */
        0,                              /* tp_itemsize */
index aae4b27..1ee0846 100644 (file)
@@ -157,8 +157,7 @@ static PyGetSetDef rpmtd_getseters[] = {
 };
 
 PyTypeObject rpmtd_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.td",                       /* tp_name */
        sizeof(rpmtdObject),            /* tp_size */
        0,                              /* tp_itemsize */
index 3a59578..48805db 100644 (file)
@@ -266,8 +266,7 @@ static char rpmte_doc[] =
 "";
 
 PyTypeObject rpmte_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.te",                       /* tp_name */
        sizeof(rpmteObject),            /* tp_size */
        0,                              /* tp_itemsize */
index df0f590..f5e0a8e 100644 (file)
@@ -813,8 +813,7 @@ static PyGetSetDef rpmts_getseters[] = {
 };
 
 PyTypeObject rpmts_Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-       0,                              /* ob_size */
+       PyVarObject_HEAD_INIT(&PyType_Type, 0)
        "rpm.ts",                       /* tp_name */
        sizeof(rpmtsObject),            /* tp_size */
        0,                              /* tp_itemsize */
index fb362f7..d2c0b30 100644 (file)
@@ -176,8 +176,7 @@ static PyObject *spec_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
 }
 
 PyTypeObject spec_Type = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,                         /*ob_size*/
+    PyVarObject_HEAD_INIT(&PyType_Type, 0)
     "rpm.spec",               /*tp_name*/
     sizeof(specObject),        /*tp_basicsize*/
     0,                         /*tp_itemsize*/