From 4b8e0ebde64321a8dbcbdce9f44557185fde1719 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 15 Oct 2009 15:14:57 -0400 Subject: Generalize type object initialization to work with both Python 2.* and Python 3.* 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 | 3 +-- python/rpmds-py.c | 3 +-- python/rpmfd-py.c | 3 +-- python/rpmfi-py.c | 3 +-- python/rpmkeyring-py.c | 6 ++---- python/rpmmi-py.c | 3 +-- python/rpmps-py.c | 6 ++---- python/rpmtd-py.c | 3 +-- python/rpmte-py.c | 3 +-- python/rpmts-py.c | 3 +-- python/spec-py.c | 3 +-- 11 files changed, 13 insertions(+), 26 deletions(-) diff --git a/python/header-py.c b/python/header-py.c index 18a7e66b9..3c2f3942a 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -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 */ diff --git a/python/rpmds-py.c b/python/rpmds-py.c index 8938cc7a1..f45c908ce 100644 --- a/python/rpmds-py.c +++ b/python/rpmds-py.c @@ -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 */ diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c index 193d8e87f..62ddeb09e 100644 --- a/python/rpmfd-py.c +++ b/python/rpmfd-py.c @@ -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 */ diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c index 5484a1bac..c6d2ba4a4 100644 --- a/python/rpmfi-py.c +++ b/python/rpmfi-py.c @@ -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 */ diff --git a/python/rpmkeyring-py.c b/python/rpmkeyring-py.c index 00be981a6..6bb27afc6 100644 --- a/python/rpmkeyring-py.c +++ b/python/rpmkeyring-py.c @@ -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 */ diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c index 0a871534d..f6dd80271 100644 --- a/python/rpmmi-py.c +++ b/python/rpmmi-py.c @@ -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 */ diff --git a/python/rpmps-py.c b/python/rpmps-py.c index 1b08e2f21..ccea5d221 100644 --- a/python/rpmps-py.c +++ b/python/rpmps-py.c @@ -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 */ diff --git a/python/rpmtd-py.c b/python/rpmtd-py.c index aae4b27f1..1ee084677 100644 --- a/python/rpmtd-py.c +++ b/python/rpmtd-py.c @@ -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 */ diff --git a/python/rpmte-py.c b/python/rpmte-py.c index 3a5957893..48805dbf6 100644 --- a/python/rpmte-py.c +++ b/python/rpmte-py.c @@ -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 */ diff --git a/python/rpmts-py.c b/python/rpmts-py.c index df0f5908d..f5e0a8ee9 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -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 */ diff --git a/python/spec-py.c b/python/spec-py.c index fb362f7e3..d2c0b301b 100644 --- a/python/spec-py.c +++ b/python/spec-py.c @@ -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*/ -- cgit v1.2.3