[Rpm-maint] [PATCH 03/15] Generalize type object initialization to work with both Python 2.* and Python 3.*
David Malcolm
dmalcolm at redhat.com
Thu Oct 15 19:14:57 UTC 2009
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 bbf698e..cd3fe5e 100644
--- a/python/header-py.c
+++ b/python/header-py.c
@@ -501,8 +501,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 8938cc7..f45c908 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 556357c..0d84c41 100644
--- a/python/rpmfd-py.c
+++ b/python/rpmfd-py.c
@@ -262,8 +262,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 5484a1b..c6d2ba4 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 00be981..6bb27af 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 0a87153..f6dd802 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 1b08e2f..ccea5d2 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 aae4b27..1ee0846 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 3a59578..48805db 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 ad70853..8c0fe36 100644
--- a/python/rpmts-py.c
+++ b/python/rpmts-py.c
@@ -811,8 +811,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 fb362f7..d2c0b30 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*/
--
1.6.2.5
More information about the Rpm-maint
mailing list