diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-09-22 21:53:21 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-09-22 21:53:21 +0300 |
commit | 864220c441704e3d61fa521c682a23874b41e4ba (patch) | |
tree | 074a4145961da5eae5857e5b6e1cc1b171cce463 /python/rpmds-py.c | |
parent | ed557bbcf065905beebb42d50048cecf04c3e441 (diff) | |
download | rpm-864220c441704e3d61fa521c682a23874b41e4ba.tar.gz rpm-864220c441704e3d61fa521c682a23874b41e4ba.tar.bz2 rpm-864220c441704e3d61fa521c682a23874b41e4ba.zip |
Put some consistency to python object creation
- all type object creation goes through foo_Wrap() which handle OOM
and all type specific initialization
Diffstat (limited to 'python/rpmds-py.c')
-rw-r--r-- | python/rpmds-py.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/python/rpmds-py.c b/python/rpmds-py.c index 25cd3e38c..0c3a45928 100644 --- a/python/rpmds-py.c +++ b/python/rpmds-py.c @@ -468,11 +468,11 @@ fprintf(stderr, "%p -- ds %p\n", s, s->ds); */ static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) { - rpmdsObject * s = (void *) PyObject_New(rpmdsObject, subtype); hdrObject * ho = NULL; PyObject * to = NULL; rpmTag tagN = RPMTAG_REQUIRENAME; rpmsenseFlags flags = 0; + rpmds ds = NULL; char * kwlist[] = {"header", "tag", "flags", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|Oi:rpmds_new", kwlist, @@ -483,9 +483,9 @@ static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kw tagN = tagNumFromPyObject(to); if (tagN == RPMTAG_NOT_FOUND) return NULL; } - s->ds = rpmdsNew(hdrGetHeader(ho), tagN, 0); + ds = rpmdsNew(hdrGetHeader(ho), tagN, 0); - return (PyObject *)s; + return rpmds_Wrap(ds); } /** @@ -549,9 +549,8 @@ rpmds dsFromDs(rpmdsObject * s) PyObject * rpmds_Wrap(rpmds ds) { rpmdsObject * s = PyObject_New(rpmdsObject, &rpmds_Type); + if (s == NULL) return PyErr_NoMemory(); - if (s == NULL) - return NULL; s->ds = ds; s->active = 0; return (PyObject *) s; |