s4-python: Only set BASETYPE flag if subclassing is supported.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 29 Dec 2010 17:56:13 +0000 (18:56 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 1 Jan 2011 02:39:58 +0000 (03:39 +0100)
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sat Jan  1 03:39:58 CET 2011 on sn-devel-104

lib/talloc/pytalloc.c
lib/tdb/pytdb.c
libcli/nbt/pynbt.c
source4/lib/ldb-samba/pyldb.c
source4/lib/ldb/pyldb.c
source4/lib/messaging/pymessaging.c
source4/librpc/rpc/pyrpc.c
source4/web_server/wsgi.c

index a8c46c96f8caa5d4138c1070a8547dfdc1cdb786..614b81f05715487941fda03d405b52f03f28a4d0 100644 (file)
@@ -96,7 +96,7 @@ static void py_talloc_dealloc(PyObject* self)
        py_talloc_Object *obj = (py_talloc_Object *)self;
        assert(talloc_unlink(NULL, obj->talloc_ctx) != -1);
        obj->talloc_ctx = NULL;
-       PyObject_Del(self);
+       self->ob_type->tp_free(self);
 }
 
 /**
@@ -112,8 +112,6 @@ static int py_talloc_default_cmp(PyObject *_obj1, PyObject *_obj2)
        return ((char *)py_talloc_get_ptr(obj1) - (char *)py_talloc_get_ptr(obj2));
 }
 
-
-
 static PyTypeObject TallocObject_Type = {
        .tp_name = "talloc.Object",
        .tp_doc = "Python wrapper for a talloc-maintained object.",
index 981459efef70f9c0707fdc664fd98ae47f43ab22..0faba562de93d028f9aacd9b51c7045b6f593caa 100644 (file)
@@ -479,7 +479,7 @@ static void tdb_object_dealloc(PyTdbObject *self)
 {
        if (!self->closed)
                tdb_close(self->ctx);
-       PyObject_Del(self);
+       self->ob_type->tp_free(self);
 }
 
 static PyObject *obj_getitem(PyTdbObject *self, PyObject *key)
index 9251ecfc428cb09462d8922fb70be45c0e89bf9b..0bba2ec7a760437373a2edfe2ef315079b947c0b 100644 (file)
@@ -38,10 +38,10 @@ typedef struct {
        struct nbt_name_socket *socket;
 } nbt_node_Object;
 
-static void py_nbt_node_dealloc(PyObject *obj)
+static void py_nbt_node_dealloc(nbt_node_Object *self)
 {
-       talloc_free(((nbt_node_Object *)obj)->mem_ctx);
-       PyObject_Del(obj);
+       talloc_free(self->mem_ctx);
+       self->ob_type->tp_free(self);
 }
 
 static PyObject *py_nbt_node_init(PyTypeObject *self, PyObject *args, PyObject *kwargs)
@@ -395,7 +395,7 @@ PyTypeObject nbt_node_Type = {
        .tp_basicsize = sizeof(nbt_node_Object),
        .tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
        .tp_new = py_nbt_node_init,
-       .tp_dealloc = py_nbt_node_dealloc,
+       .tp_dealloc = (destructor)py_nbt_node_dealloc,
        .tp_methods = py_nbt_methods,
        .tp_doc = "Node()\n"
                  "Create a new NetBIOS node\n"
index cce653e20ac72ab36b5c445748ee5399b472de11..472a4664ea16357c8720fd291ea5e2cac9d827cb 100644 (file)
@@ -45,8 +45,6 @@ static void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_
                        ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx)));
 }
 
-
-
 static PyObject *py_ldb_set_loadparm(PyObject *self, PyObject *args)
 {
        PyObject *py_lp_ctx;
@@ -116,33 +114,33 @@ static PyObject *py_ldb_set_opaque_integer(PyObject *self, PyObject *args)
        if (old_val) {
                *old_val = value;
                Py_RETURN_NONE;
-       } 
+       }
 
        tmp_ctx = talloc_new(ldb);
        if (tmp_ctx == NULL) {
                PyErr_NoMemory();
                return NULL;
        }
-       
+
        new_val = talloc(tmp_ctx, int);
        if (new_val == NULL) {
                talloc_free(tmp_ctx);
                PyErr_NoMemory();
                return NULL;
        }
-       
+
        opaque_name_talloc = talloc_strdup(tmp_ctx, py_opaque_name);
        if (opaque_name_talloc == NULL) {
                talloc_free(tmp_ctx);
                PyErr_NoMemory();
                return NULL;
        }
-       
+
        *new_val = value;
 
        /* cache the domain_sid in the ldb */
        ret = ldb_set_opaque(ldb, opaque_name_talloc, new_val);
-       
+
        if (ret != LDB_SUCCESS) {
                talloc_free(tmp_ctx);
                PyErr_SetLdbError(py_ldb_error, ret, ldb);
@@ -240,13 +238,12 @@ static PyMethodDef py_samba_ldb_methods[] = {
 };
 
 static PyTypeObject PySambaLdb = {
-       .tp_name = "samba.Ldb",
+       .tp_name = "samba._ldb.Ldb",
        .tp_doc = "Connection to a LDB database.",
        .tp_methods = py_samba_ldb_methods,
        .tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
 };
 
-
 void init_ldb(void)
 {
        PyObject *m;
index 71720d60e0cf7279788d0ad8cca45f45ae2de9e5..354e83d8d33be29aa55386ac6d2be1a6b57fd8e6 100644 (file)
@@ -8,9 +8,9 @@
    Copyright (C) 2007-2010 Jelmer Vernooij <jelmer@samba.org>
    Copyright (C) 2009-2010 Matthias Dieter Wallnöfer
 
-        ** NOTE! The following LGPL license applies to the ldb
-        ** library. This does NOT imply that all of Samba is released
-        ** under the LGPL
+    ** NOTE! The following LGPL license applies to the ldb
+    ** library. This does NOT imply that all of Samba is released
+    ** under the LGPL
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -1502,7 +1502,7 @@ static PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx)
 static void py_ldb_dealloc(PyLdbObject *self)
 {
        talloc_free(self->mem_ctx);
-       PyObject_Del(self);
+       self->ob_type->tp_free(self);
 }
 
 PyTypeObject PyLdb = {
index 9854f4f95ef830b06754586403be1b9ad88cbc7d..aece5efd09a81678f67c8bad9596528c76fc7237 100644 (file)
@@ -61,7 +61,7 @@ typedef struct {
        struct messaging_context *msg_ctx;
 } messaging_Object;
 
-PyObject *py_messaging_connect(PyTypeObject *self, PyObject *args, PyObject *kwargs)
+static PyObject *py_messaging_connect(PyTypeObject *self, PyObject *args, PyObject *kwargs)
 {
        struct tevent_context *ev;
        const char *kwnames[] = { "own_id", "messaging_path", NULL };
@@ -118,7 +118,7 @@ static void py_messaging_dealloc(PyObject *self)
 {
        messaging_Object *iface = (messaging_Object *)self;
        talloc_free(iface->msg_ctx);
-       PyObject_Del(self);
+       self->ob_type->tp_free(self);
 }
 
 static PyObject *py_messaging_send(PyObject *self, PyObject *args, PyObject *kwargs)
index 46f1f061a8fd99b901cff34cd9bb4810c62394a3..ffd2376c7497d046bcf74cb66d09d88a901b1ac7 100644 (file)
@@ -219,12 +219,11 @@ static PyMethodDef dcerpc_interface_methods[] = {
        { NULL, NULL, 0, NULL },
 };
 
-
 static void dcerpc_interface_dealloc(PyObject* self)
 {
        dcerpc_InterfaceObject *interface = (dcerpc_InterfaceObject *)self;
        talloc_free(interface->mem_ctx);
-       PyObject_Del(self);
+       self->ob_type->tp_free(self);
 }
 
 static PyObject *dcerpc_interface_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
index 73e668ebfd7c6ce4eef945a33906080a45b367f0..1c105d0337e7297de8ff7a4b79e99cd4bccc39e4 100644 (file)
@@ -111,7 +111,7 @@ PyTypeObject web_request_Type = {
        .tp_name = "wsgi.Request",
        .tp_methods = web_request_methods,
        .tp_basicsize = sizeof(web_request_Object),
-       .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+       .tp_flags = Py_TPFLAGS_DEFAULT,
 };
 
 typedef struct {
@@ -168,7 +168,7 @@ PyTypeObject error_Stream_Type = {
        .tp_name = "wsgi.ErrorStream",
        .tp_basicsize = sizeof(error_Stream_Object),
        .tp_methods = error_Stream_methods,
-       .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+       .tp_flags = Py_TPFLAGS_DEFAULT,
 };
 
 typedef struct {
@@ -242,7 +242,7 @@ PyTypeObject input_Stream_Type = {
        .tp_name = "wsgi.InputStream",
        .tp_basicsize = sizeof(input_Stream_Object),
        .tp_methods = input_Stream_methods,
-       .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+       .tp_flags = Py_TPFLAGS_DEFAULT,
 };
 
 static PyObject *Py_InputHttpStream(struct websrv_context *web)