Generalize access to ob_type so that they work with both Python 2.* and Python 3.*
Python 2's various object structs use macros to implement common fields at the top of each struct. Python 3's objects instead embed a PyObject struct as the first member within the more refined object structs. Use the Py_TYPE() macro when accessing ob_type in order to encapsulate this difference.
This commit is contained in:
parent
63175d4d31
commit
7b51c4a1eb
|
@ -395,7 +395,7 @@ static PyObject *hdr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
|
|||
static void hdr_dealloc(hdrObject * s)
|
||||
{
|
||||
if (s->h) headerFree(s->h);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static PyObject * hdr_iternext(hdrObject *s)
|
||||
|
|
|
@ -199,7 +199,7 @@ rpmds_iternext(rpmdsObject * s)
|
|||
rpmTag tagN = rpmdsTagN(s->ds);
|
||||
rpmsenseFlags Flags = rpmdsFlags(s->ds);
|
||||
|
||||
result = rpmds_Wrap(s->ob_type, rpmdsSingle(tagN, N, EVR, Flags) );
|
||||
result = rpmds_Wrap(Py_TYPE(s), rpmdsSingle(tagN, N, EVR, Flags) );
|
||||
} else
|
||||
s->active = 0;
|
||||
|
||||
|
@ -381,7 +381,7 @@ static void
|
|||
rpmds_dealloc(rpmdsObject * s)
|
||||
{
|
||||
s->ds = rpmdsFree(s->ds);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static Py_ssize_t rpmds_length(rpmdsObject * s)
|
||||
|
|
|
@ -107,7 +107,7 @@ static void rpmfd_dealloc(rpmfdObject *s)
|
|||
{
|
||||
PyObject *res = do_close(s);
|
||||
Py_XDECREF(res);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static PyObject *rpmfd_fileno(rpmfdObject *s)
|
||||
|
|
|
@ -258,7 +258,7 @@ static void
|
|||
rpmfi_dealloc(rpmfiObject * s)
|
||||
{
|
||||
s->fi = rpmfiFree(s->fi);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -11,7 +11,7 @@ struct rpmPubkeyObject_s {
|
|||
static void rpmPubkey_dealloc(rpmPubkeyObject * s)
|
||||
{
|
||||
s->pubkey = rpmPubkeyFree(s->pubkey);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static PyObject *rpmPubkey_new(PyTypeObject *subtype,
|
||||
|
@ -103,7 +103,7 @@ struct rpmKeyringObject_s {
|
|||
static void rpmKeyring_dealloc(rpmKeyringObject * s)
|
||||
{
|
||||
rpmKeyringFree(s->keyring);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static PyObject *rpmKeyring_new(PyTypeObject *subtype,
|
||||
|
|
|
@ -129,7 +129,7 @@ static void rpmmi_dealloc(rpmmiObject * s)
|
|||
{
|
||||
s->mi = rpmdbFreeIterator(s->mi);
|
||||
Py_DECREF(s->ref);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static Py_ssize_t rpmmi_length(rpmmiObject * s)
|
||||
|
|
|
@ -175,7 +175,7 @@ static void
|
|||
rpmps_dealloc(rpmpsObject * s)
|
||||
{
|
||||
s->ps = rpmpsFree(s->ps);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -117,7 +117,7 @@ static PyObject *rpmtd_new(PyTypeObject * subtype, PyObject *args, PyObject *kwd
|
|||
static void rpmtd_dealloc(rpmtdObject * s)
|
||||
{
|
||||
rpmtdFreeData(&(s->td));
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static int rpmtd_length(rpmtdObject *s)
|
||||
|
|
|
@ -677,7 +677,7 @@ static void rpmts_dealloc(rpmtsObject * s)
|
|||
|
||||
s->ts = rpmtsFree(s->ts);
|
||||
Py_XDECREF(s->scriptFd);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
|
||||
|
|
|
@ -40,7 +40,7 @@ spec_dealloc(specObject * s)
|
|||
if (s->spec) {
|
||||
s->spec=freeSpec(s->spec);
|
||||
}
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
/* XXX TODO return something sensible if spec exists but component (eg %clean)
|
||||
|
|
Loading…
Reference in New Issue