py_passdb: Use pytalloc_BaseObject_PyType_Ready()
authorAndrew Bartlett <abartlet@samba.org>
Mon, 29 Feb 2016 20:30:03 +0000 (09:30 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 8 Mar 2016 00:58:29 +0000 (01:58 +0100)
This changes py_passdb to use talloc.BaseObject() just like the PIDL output

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source3/passdb/py_passdb.c

index 9786f143bd9fcf5da3caf2279b5903691eb2baf7..c49354c7765e345ae9105c44f994a9b2ead769f7 100644 (file)
@@ -1108,7 +1108,6 @@ static PyObject *py_samu_new(PyTypeObject *type, PyObject *args, PyObject *kwarg
 
 static PyTypeObject PySamu = {
        .tp_name = "passdb.Samu",
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_getset = py_samu_getsetters,
        .tp_methods = NULL,
        .tp_new = py_samu_new,
@@ -1311,7 +1310,6 @@ static PyObject *py_groupmap_new(PyTypeObject *type, PyObject *args, PyObject *k
 
 static PyTypeObject PyGroupmap = {
        .tp_name = "passdb.Groupmap",
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_getset = py_groupmap_getsetters,
        .tp_methods = NULL,
        .tp_new = py_groupmap_new,
@@ -3569,7 +3567,6 @@ static PyObject *py_pdb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs
 
 static PyTypeObject PyPDB = {
        .tp_name = "passdb.PDB",
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_pdb_new,
        .tp_flags = Py_TPFLAGS_DEFAULT,
        .tp_methods = py_pdb_methods,
@@ -3713,26 +3710,17 @@ void initpassdb(void)
        PyObject *m, *mod;
        char exception_name[] = "passdb.error";
 
-       PyTypeObject *talloc_type = pytalloc_GetObjectType();
-       if (talloc_type == NULL) {
+       if (pytalloc_BaseObject_PyType_Ready(&PyPDB) < 0) {
                talloc_free(frame);
                return;
        }
 
-       PyPDB.tp_base = talloc_type;
-       if (PyType_Ready(&PyPDB) < 0) {
+       if (pytalloc_BaseObject_PyType_Ready(&PySamu) < 0) {
                talloc_free(frame);
                return;
        }
 
-       PySamu.tp_base = talloc_type;
-       if (PyType_Ready(&PySamu) < 0) {
-               talloc_free(frame);
-               return;
-       }
-
-       PyGroupmap.tp_base = talloc_type;
-       if (PyType_Ready(&PyGroupmap) < 0) {
+       if (pytalloc_BaseObject_PyType_Ready(&PyGroupmap) < 0) {
                talloc_free(frame);
                return;
        }