git add -f bin/default/librpc/gen_ndr/*.{c,h,ndr,pidl} bin/default/source*/librpc...
[metze/samba/wip.git] / bin / default / librpc / gen_ndr / py_echo.c
index 073cf45307872e50c9ac2801a31d5d86ee9a7afd..22bafbf221a4e563df38cd95630941b5f3f6a845 100644 (file)
@@ -1,5 +1,6 @@
 
 /* Python wrapper functions auto-generated by pidl */
+#define PY_SSIZE_T_CLEAN 1 /* We use Py_ssize_t for PyArg_ParseTupleAndKeywords */
 #include <Python.h>
 #include "includes.h"
 #include <pytalloc.h>
@@ -9,7 +10,7 @@
 #include "bin/default/librpc/gen_ndr/ndr_echo_c.h"
 
 /*
- * These functions are here to ensure they can be optomised out by
+ * These functions are here to ensure they can be optimized out by
  * the compiler based on the constant input values
  */
 
@@ -78,7 +79,7 @@ union echo_Enum3 *py_export_echo_Enum3(TALLOC_CTX *mem_ctx, int level, PyObject
 static PyTypeObject echo_Surrounding_Type;
 static PyTypeObject rpcecho_InterfaceType;
 
-void initecho(void);static PyTypeObject *Object_Type;
+void initecho(void);static PyTypeObject *BaseObject_Type;
 static PyTypeObject *ClientConnection_Type;
 static PyTypeObject *ndr_syntax_id_Type;
 
@@ -93,6 +94,10 @@ static PyObject *py_echo_info1_get_v(PyObject *obj, void *closure)
 static int py_echo_info1_set_v(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_info1 *object = (struct echo_info1 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->v");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v));
                if (PyLong_Check(value)) {
@@ -126,8 +131,13 @@ static int py_echo_info1_set_v(PyObject *py_obj, PyObject *value, void *closure)
 }
 
 static PyGetSetDef py_echo_info1_getsetters[] = {
-       { discard_const_p(char, "v"), py_echo_info1_get_v, py_echo_info1_set_v },
-       { NULL }
+       {
+               .name = discard_const_p(char, "v"),
+               .get = py_echo_info1_get_v,
+               .set = py_echo_info1_set_v,
+               .doc = discard_const_p(char, "PIDL-generated element v")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_echo_info1_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -138,22 +148,31 @@ static PyObject *py_echo_info1_new(PyTypeObject *type, PyObject *args, PyObject
 static PyObject *py_echo_info1_ndr_pack(PyObject *py_obj)
 {
        struct echo_info1 *object = (struct echo_info1 *)pytalloc_get_ptr(py_obj);
+       PyObject *ret = NULL;
        DATA_BLOB blob;
        enum ndr_err_code err;
-       err = ndr_push_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_echo_info1);
+       TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
+       if (tmp_ctx == NULL) {
+               PyErr_SetNdrError(NDR_ERR_ALLOC);
+               return NULL;
+       }
+       err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_echo_info1);
        if (err != NDR_ERR_SUCCESS) {
+               TALLOC_FREE(tmp_ctx);
                PyErr_SetNdrError(err);
                return NULL;
        }
 
-       return PyString_FromStringAndSize((char *)blob.data, blob.length);
+       ret = PyString_FromStringAndSize((char *)blob.data, blob.length);
+       TALLOC_FREE(tmp_ctx);
+       return ret;
 }
 
 static PyObject *py_echo_info1_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
 {
        struct echo_info1 *object = (struct echo_info1 *)pytalloc_get_ptr(py_obj);
        DATA_BLOB blob;
-       int blob_length = 0;
+       Py_ssize_t blob_length = 0;
        enum ndr_err_code err;
        const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
        PyObject *allow_remaining_obj = NULL;
@@ -211,7 +230,6 @@ static PyTypeObject echo_info1_Type = {
        .tp_getset = py_echo_info1_getsetters,
        .tp_methods = py_echo_info1_methods,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_echo_info1_new,
 };
 
@@ -227,6 +245,10 @@ static PyObject *py_echo_info2_get_v(PyObject *obj, void *closure)
 static int py_echo_info2_set_v(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_info2 *object = (struct echo_info2 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->v");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v));
                if (PyLong_Check(value)) {
@@ -260,8 +282,13 @@ static int py_echo_info2_set_v(PyObject *py_obj, PyObject *value, void *closure)
 }
 
 static PyGetSetDef py_echo_info2_getsetters[] = {
-       { discard_const_p(char, "v"), py_echo_info2_get_v, py_echo_info2_set_v },
-       { NULL }
+       {
+               .name = discard_const_p(char, "v"),
+               .get = py_echo_info2_get_v,
+               .set = py_echo_info2_set_v,
+               .doc = discard_const_p(char, "PIDL-generated element v")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_echo_info2_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -276,7 +303,6 @@ static PyTypeObject echo_info2_Type = {
        .tp_getset = py_echo_info2_getsetters,
        .tp_methods = NULL,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_echo_info2_new,
 };
 
@@ -292,6 +318,10 @@ static PyObject *py_echo_info3_get_v(PyObject *obj, void *closure)
 static int py_echo_info3_set_v(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_info3 *object = (struct echo_info3 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->v");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v));
                if (PyLong_Check(value)) {
@@ -325,8 +355,13 @@ static int py_echo_info3_set_v(PyObject *py_obj, PyObject *value, void *closure)
 }
 
 static PyGetSetDef py_echo_info3_getsetters[] = {
-       { discard_const_p(char, "v"), py_echo_info3_get_v, py_echo_info3_set_v },
-       { NULL }
+       {
+               .name = discard_const_p(char, "v"),
+               .get = py_echo_info3_get_v,
+               .set = py_echo_info3_set_v,
+               .doc = discard_const_p(char, "PIDL-generated element v")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_echo_info3_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -341,7 +376,6 @@ static PyTypeObject echo_info3_Type = {
        .tp_getset = py_echo_info3_getsetters,
        .tp_methods = NULL,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_echo_info3_new,
 };
 
@@ -357,6 +391,10 @@ static PyObject *py_echo_info4_get_v(PyObject *obj, void *closure)
 static int py_echo_info4_set_v(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_info4 *object = (struct echo_info4 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->v");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v));
                if (PyLong_Check(value)) {
@@ -390,8 +428,13 @@ static int py_echo_info4_set_v(PyObject *py_obj, PyObject *value, void *closure)
 }
 
 static PyGetSetDef py_echo_info4_getsetters[] = {
-       { discard_const_p(char, "v"), py_echo_info4_get_v, py_echo_info4_set_v },
-       { NULL }
+       {
+               .name = discard_const_p(char, "v"),
+               .get = py_echo_info4_get_v,
+               .set = py_echo_info4_set_v,
+               .doc = discard_const_p(char, "PIDL-generated element v")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_echo_info4_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -406,7 +449,6 @@ static PyTypeObject echo_info4_Type = {
        .tp_getset = py_echo_info4_getsetters,
        .tp_methods = NULL,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_echo_info4_new,
 };
 
@@ -422,6 +464,10 @@ static PyObject *py_echo_info5_get_v1(PyObject *obj, void *closure)
 static int py_echo_info5_set_v1(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_info5 *object = (struct echo_info5 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->v1");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v1));
                if (PyLong_Check(value)) {
@@ -465,6 +511,10 @@ static PyObject *py_echo_info5_get_v2(PyObject *obj, void *closure)
 static int py_echo_info5_set_v2(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_info5 *object = (struct echo_info5 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->v2");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v2));
                if (PyLong_Check(value)) {
@@ -498,9 +548,19 @@ static int py_echo_info5_set_v2(PyObject *py_obj, PyObject *value, void *closure
 }
 
 static PyGetSetDef py_echo_info5_getsetters[] = {
-       { discard_const_p(char, "v1"), py_echo_info5_get_v1, py_echo_info5_set_v1 },
-       { discard_const_p(char, "v2"), py_echo_info5_get_v2, py_echo_info5_set_v2 },
-       { NULL }
+       {
+               .name = discard_const_p(char, "v1"),
+               .get = py_echo_info5_get_v1,
+               .set = py_echo_info5_set_v1,
+               .doc = discard_const_p(char, "PIDL-generated element v1")
+       },
+       {
+               .name = discard_const_p(char, "v2"),
+               .get = py_echo_info5_get_v2,
+               .set = py_echo_info5_set_v2,
+               .doc = discard_const_p(char, "PIDL-generated element v2")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_echo_info5_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -515,7 +575,6 @@ static PyTypeObject echo_info5_Type = {
        .tp_getset = py_echo_info5_getsetters,
        .tp_methods = NULL,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_echo_info5_new,
 };
 
@@ -531,6 +590,10 @@ static PyObject *py_echo_info6_get_v1(PyObject *obj, void *closure)
 static int py_echo_info6_set_v1(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_info6 *object = (struct echo_info6 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->v1");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v1));
                if (PyLong_Check(value)) {
@@ -574,6 +637,10 @@ static PyObject *py_echo_info6_get_info1(PyObject *obj, void *closure)
 static int py_echo_info6_set_info1(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_info6 *object = (struct echo_info6 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->info1");
+               return -1;
+       }
        PY_CHECK_TYPE(&echo_info1_Type, value, return -1;);
        if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
                PyErr_NoMemory();
@@ -584,9 +651,19 @@ static int py_echo_info6_set_info1(PyObject *py_obj, PyObject *value, void *clos
 }
 
 static PyGetSetDef py_echo_info6_getsetters[] = {
-       { discard_const_p(char, "v1"), py_echo_info6_get_v1, py_echo_info6_set_v1 },
-       { discard_const_p(char, "info1"), py_echo_info6_get_info1, py_echo_info6_set_info1 },
-       { NULL }
+       {
+               .name = discard_const_p(char, "v1"),
+               .get = py_echo_info6_get_v1,
+               .set = py_echo_info6_set_v1,
+               .doc = discard_const_p(char, "PIDL-generated element v1")
+       },
+       {
+               .name = discard_const_p(char, "info1"),
+               .get = py_echo_info6_get_info1,
+               .set = py_echo_info6_set_info1,
+               .doc = discard_const_p(char, "PIDL-generated element info1")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_echo_info6_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -601,7 +678,6 @@ static PyTypeObject echo_info6_Type = {
        .tp_getset = py_echo_info6_getsetters,
        .tp_methods = NULL,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_echo_info6_new,
 };
 
@@ -617,6 +693,10 @@ static PyObject *py_echo_info7_get_v1(PyObject *obj, void *closure)
 static int py_echo_info7_set_v1(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_info7 *object = (struct echo_info7 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->v1");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v1));
                if (PyLong_Check(value)) {
@@ -660,6 +740,10 @@ static PyObject *py_echo_info7_get_info4(PyObject *obj, void *closure)
 static int py_echo_info7_set_info4(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_info7 *object = (struct echo_info7 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->info4");
+               return -1;
+       }
        PY_CHECK_TYPE(&echo_info4_Type, value, return -1;);
        if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
                PyErr_NoMemory();
@@ -670,9 +754,19 @@ static int py_echo_info7_set_info4(PyObject *py_obj, PyObject *value, void *clos
 }
 
 static PyGetSetDef py_echo_info7_getsetters[] = {
-       { discard_const_p(char, "v1"), py_echo_info7_get_v1, py_echo_info7_set_v1 },
-       { discard_const_p(char, "info4"), py_echo_info7_get_info4, py_echo_info7_set_info4 },
-       { NULL }
+       {
+               .name = discard_const_p(char, "v1"),
+               .get = py_echo_info7_get_v1,
+               .set = py_echo_info7_set_v1,
+               .doc = discard_const_p(char, "PIDL-generated element v1")
+       },
+       {
+               .name = discard_const_p(char, "info4"),
+               .get = py_echo_info7_get_info4,
+               .set = py_echo_info7_set_info4,
+               .doc = discard_const_p(char, "PIDL-generated element info4")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_echo_info7_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -687,7 +781,6 @@ static PyTypeObject echo_info7_Type = {
        .tp_getset = py_echo_info7_getsetters,
        .tp_methods = NULL,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_echo_info7_new,
 };
 
@@ -734,6 +827,10 @@ union echo_Info *py_export_echo_Info(TALLOC_CTX *mem_ctx, int level, PyObject *i
        union echo_Info *ret = talloc_zero(mem_ctx, union echo_Info);
        switch (level) {
                case 1:
+                       if (in == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->info1");
+                               talloc_free(ret); return NULL;
+                       }
                        PY_CHECK_TYPE(&echo_info1_Type, in, talloc_free(ret); return NULL;);
                        if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
                                PyErr_NoMemory();
@@ -743,6 +840,10 @@ union echo_Info *py_export_echo_Info(TALLOC_CTX *mem_ctx, int level, PyObject *i
                        break;
 
                case 2:
+                       if (in == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->info2");
+                               talloc_free(ret); return NULL;
+                       }
                        PY_CHECK_TYPE(&echo_info2_Type, in, talloc_free(ret); return NULL;);
                        if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
                                PyErr_NoMemory();
@@ -752,6 +853,10 @@ union echo_Info *py_export_echo_Info(TALLOC_CTX *mem_ctx, int level, PyObject *i
                        break;
 
                case 3:
+                       if (in == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->info3");
+                               talloc_free(ret); return NULL;
+                       }
                        PY_CHECK_TYPE(&echo_info3_Type, in, talloc_free(ret); return NULL;);
                        if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
                                PyErr_NoMemory();
@@ -761,6 +866,10 @@ union echo_Info *py_export_echo_Info(TALLOC_CTX *mem_ctx, int level, PyObject *i
                        break;
 
                case 4:
+                       if (in == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->info4");
+                               talloc_free(ret); return NULL;
+                       }
                        PY_CHECK_TYPE(&echo_info4_Type, in, talloc_free(ret); return NULL;);
                        if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
                                PyErr_NoMemory();
@@ -770,6 +879,10 @@ union echo_Info *py_export_echo_Info(TALLOC_CTX *mem_ctx, int level, PyObject *i
                        break;
 
                case 5:
+                       if (in == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->info5");
+                               talloc_free(ret); return NULL;
+                       }
                        PY_CHECK_TYPE(&echo_info5_Type, in, talloc_free(ret); return NULL;);
                        if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
                                PyErr_NoMemory();
@@ -779,6 +892,10 @@ union echo_Info *py_export_echo_Info(TALLOC_CTX *mem_ctx, int level, PyObject *i
                        break;
 
                case 6:
+                       if (in == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->info6");
+                               talloc_free(ret); return NULL;
+                       }
                        PY_CHECK_TYPE(&echo_info6_Type, in, talloc_free(ret); return NULL;);
                        if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
                                PyErr_NoMemory();
@@ -788,6 +905,10 @@ union echo_Info *py_export_echo_Info(TALLOC_CTX *mem_ctx, int level, PyObject *i
                        break;
 
                case 7:
+                       if (in == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->info7");
+                               talloc_free(ret); return NULL;
+                       }
                        PY_CHECK_TYPE(&echo_info7_Type, in, talloc_free(ret); return NULL;);
                        if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
                                PyErr_NoMemory();
@@ -817,6 +938,10 @@ static PyObject *py_echo_Enum2_get_e1(PyObject *obj, void *closure)
 static int py_echo_Enum2_set_e1(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_Enum2 *object = (struct echo_Enum2 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->e1");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->e1));
                if (PyLong_Check(value)) {
@@ -860,6 +985,10 @@ static PyObject *py_echo_Enum2_get_e2(PyObject *obj, void *closure)
 static int py_echo_Enum2_set_e2(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_Enum2 *object = (struct echo_Enum2 *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->e2");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->e2));
                if (PyLong_Check(value)) {
@@ -893,9 +1022,19 @@ static int py_echo_Enum2_set_e2(PyObject *py_obj, PyObject *value, void *closure
 }
 
 static PyGetSetDef py_echo_Enum2_getsetters[] = {
-       { discard_const_p(char, "e1"), py_echo_Enum2_get_e1, py_echo_Enum2_set_e1 },
-       { discard_const_p(char, "e2"), py_echo_Enum2_get_e2, py_echo_Enum2_set_e2 },
-       { NULL }
+       {
+               .name = discard_const_p(char, "e1"),
+               .get = py_echo_Enum2_get_e1,
+               .set = py_echo_Enum2_set_e1,
+               .doc = discard_const_p(char, "PIDL-generated element e1")
+       },
+       {
+               .name = discard_const_p(char, "e2"),
+               .get = py_echo_Enum2_get_e2,
+               .set = py_echo_Enum2_set_e2,
+               .doc = discard_const_p(char, "PIDL-generated element e2")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_echo_Enum2_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -910,7 +1049,6 @@ static PyTypeObject echo_Enum2_Type = {
        .tp_getset = py_echo_Enum2_getsetters,
        .tp_methods = NULL,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_echo_Enum2_new,
 };
 
@@ -937,6 +1075,10 @@ union echo_Enum3 *py_export_echo_Enum3(TALLOC_CTX *mem_ctx, int level, PyObject
        union echo_Enum3 *ret = talloc_zero(mem_ctx, union echo_Enum3);
        switch (level) {
                case ECHO_ENUM1:
+                       if (in == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->e1");
+                               talloc_free(ret); return NULL;
+                       }
                        {
                                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(ret->e1));
                                if (PyLong_Check(in)) {
@@ -969,6 +1111,10 @@ union echo_Enum3 *py_export_echo_Enum3(TALLOC_CTX *mem_ctx, int level, PyObject
                        break;
 
                case ECHO_ENUM2:
+                       if (in == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->e2");
+                               talloc_free(ret); return NULL;
+                       }
                        PY_CHECK_TYPE(&echo_Enum2_Type, in, talloc_free(ret); return NULL;);
                        if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
                                PyErr_NoMemory();
@@ -998,6 +1144,10 @@ static PyObject *py_echo_Surrounding_get_x(PyObject *obj, void *closure)
 static int py_echo_Surrounding_set_x(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_Surrounding *object = (struct echo_Surrounding *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->x");
+               return -1;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->x));
                if (PyLong_Check(value)) {
@@ -1052,6 +1202,10 @@ static PyObject *py_echo_Surrounding_get_surrounding(PyObject *obj, void *closur
 static int py_echo_Surrounding_set_surrounding(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct echo_Surrounding *object = (struct echo_Surrounding *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->surrounding");
+               return -1;
+       }
        PY_CHECK_TYPE(&PyList_Type, value, return -1;);
        {
                int surrounding_cntr_0;
@@ -1059,6 +1213,10 @@ static int py_echo_Surrounding_set_surrounding(PyObject *py_obj, PyObject *value
                if (!object->surrounding) { return -1;; }
                talloc_set_name_const(object->surrounding, "ARRAY: object->surrounding");
                for (surrounding_cntr_0 = 0; surrounding_cntr_0 < PyList_GET_SIZE(value); surrounding_cntr_0++) {
+                       if (PyList_GET_ITEM(value, surrounding_cntr_0) == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->surrounding[surrounding_cntr_0]");
+                               return -1;
+                       }
                        {
                                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->surrounding[surrounding_cntr_0]));
                                if (PyLong_Check(PyList_GET_ITEM(value, surrounding_cntr_0))) {
@@ -1094,9 +1252,19 @@ static int py_echo_Surrounding_set_surrounding(PyObject *py_obj, PyObject *value
 }
 
 static PyGetSetDef py_echo_Surrounding_getsetters[] = {
-       { discard_const_p(char, "x"), py_echo_Surrounding_get_x, py_echo_Surrounding_set_x },
-       { discard_const_p(char, "surrounding"), py_echo_Surrounding_get_surrounding, py_echo_Surrounding_set_surrounding },
-       { NULL }
+       {
+               .name = discard_const_p(char, "x"),
+               .get = py_echo_Surrounding_get_x,
+               .set = py_echo_Surrounding_set_x,
+               .doc = discard_const_p(char, "PIDL-generated element x")
+       },
+       {
+               .name = discard_const_p(char, "surrounding"),
+               .get = py_echo_Surrounding_get_surrounding,
+               .set = py_echo_Surrounding_set_surrounding,
+               .doc = discard_const_p(char, "PIDL-generated element surrounding")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_echo_Surrounding_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -1111,7 +1279,6 @@ static PyTypeObject echo_Surrounding_Type = {
        .tp_getset = py_echo_Surrounding_getsetters,
        .tp_methods = NULL,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_echo_Surrounding_new,
 };
 
@@ -1127,6 +1294,10 @@ static bool pack_py_echo_AddOne_args_in(PyObject *args, PyObject *kwargs, struct
                return false;
        }
 
+       if (py_in_data == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.in_data");
+               return false;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.in_data));
                if (PyLong_Check(py_in_data)) {
@@ -1181,6 +1352,10 @@ static bool pack_py_echo_EchoData_args_in(PyObject *args, PyObject *kwargs, stru
 
        PY_CHECK_TYPE(&PyList_Type, py_in_data, return false;);
        r->in.len = PyList_GET_SIZE(py_in_data);
+       if (py_in_data == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.in_data");
+               return false;
+       }
        PY_CHECK_TYPE(&PyList_Type, py_in_data, return false;);
        {
                int in_data_cntr_0;
@@ -1188,6 +1363,10 @@ static bool pack_py_echo_EchoData_args_in(PyObject *args, PyObject *kwargs, stru
                if (!r->in.in_data) { return false;; }
                talloc_set_name_const(r->in.in_data, "ARRAY: r->in.in_data");
                for (in_data_cntr_0 = 0; in_data_cntr_0 < PyList_GET_SIZE(py_in_data); in_data_cntr_0++) {
+                       if (PyList_GET_ITEM(py_in_data, in_data_cntr_0) == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.in_data[in_data_cntr_0]");
+                               return false;
+                       }
                        {
                                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.in_data[in_data_cntr_0]));
                                if (PyLong_Check(PyList_GET_ITEM(py_in_data, in_data_cntr_0))) {
@@ -1255,6 +1434,10 @@ static bool pack_py_echo_SinkData_args_in(PyObject *args, PyObject *kwargs, stru
 
        PY_CHECK_TYPE(&PyList_Type, py_data, return false;);
        r->in.len = PyList_GET_SIZE(py_data);
+       if (py_data == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.data");
+               return false;
+       }
        PY_CHECK_TYPE(&PyList_Type, py_data, return false;);
        {
                int data_cntr_0;
@@ -1262,6 +1445,10 @@ static bool pack_py_echo_SinkData_args_in(PyObject *args, PyObject *kwargs, stru
                if (!r->in.data) { return false;; }
                talloc_set_name_const(r->in.data, "ARRAY: r->in.data");
                for (data_cntr_0 = 0; data_cntr_0 < PyList_GET_SIZE(py_data); data_cntr_0++) {
+                       if (PyList_GET_ITEM(py_data, data_cntr_0) == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.data[data_cntr_0]");
+                               return false;
+                       }
                        {
                                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.data[data_cntr_0]));
                                if (PyLong_Check(PyList_GET_ITEM(py_data, data_cntr_0))) {
@@ -1315,6 +1502,10 @@ static bool pack_py_echo_SourceData_args_in(PyObject *args, PyObject *kwargs, st
                return false;
        }
 
+       if (py_len == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.len");
+               return false;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.len));
                if (PyLong_Check(py_len)) {
@@ -1378,15 +1569,42 @@ static bool pack_py_echo_TestCall_args_in(PyObject *args, PyObject *kwargs, stru
                return false;
        }
 
+       if (py_s1 == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.s1");
+               return false;
+       }
        r->in.s1 = talloc_ptrtype(r, r->in.s1);
-       if (PyUnicode_Check(py_s1)) {
-               r->in.s1 = PyString_AS_STRING(PyUnicode_AsEncodedString(py_s1, "utf-8", "ignore"));
-       } else if (PyString_Check(py_s1)) {
-               r->in.s1 = PyString_AS_STRING(py_s1);
-       } else {
-               PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_s1)->tp_name);
+       if (py_s1 == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.s1");
                return false;
        }
+       {
+               const char *test_str;
+               const char *talloc_str;
+               PyObject *unicode = NULL;
+               if (PyUnicode_Check(py_s1)) {
+                       unicode = PyUnicode_AsEncodedString(py_s1, "utf-8", "ignore");
+                       if (unicode == NULL) {
+                               PyErr_NoMemory();
+                               return false;
+                       }
+                       test_str = PyString_AS_STRING(unicode);
+               } else if (PyString_Check(py_s1)) {
+                       test_str = PyString_AS_STRING(py_s1);
+               } else {
+                       PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_s1)->tp_name);
+                       return false;
+               }
+               talloc_str = talloc_strdup(r, test_str);
+               if (unicode != NULL) {
+                       Py_DECREF(unicode);
+               }
+               if (talloc_str == NULL) {
+                       PyErr_NoMemory();
+                       return false;
+               }
+               r->in.s1 = talloc_str;
+       }
        return true;
 }
 
@@ -1420,6 +1638,10 @@ static bool pack_py_echo_TestCall2_args_in(PyObject *args, PyObject *kwargs, str
                return false;
        }
 
+       if (py_level == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.level");
+               return false;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.level));
                if (PyLong_Check(py_level)) {
@@ -1480,6 +1702,10 @@ static bool pack_py_echo_TestSleep_args_in(PyObject *args, PyObject *kwargs, str
                return false;
        }
 
+       if (py_seconds == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.seconds");
+               return false;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.seconds));
                if (PyLong_Check(py_seconds)) {
@@ -1532,7 +1758,15 @@ static bool pack_py_echo_TestEnum_args_in(PyObject *args, PyObject *kwargs, stru
                return false;
        }
 
+       if (py_foo1 == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.foo1");
+               return false;
+       }
        r->in.foo1 = talloc_ptrtype(r, r->in.foo1);
+       if (py_foo1 == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.foo1");
+               return false;
+       }
        {
                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.foo1));
                if (PyLong_Check(py_foo1)) {
@@ -1562,14 +1796,30 @@ static bool pack_py_echo_TestEnum_args_in(PyObject *args, PyObject *kwargs, stru
                        return false;
                }
        }
+       if (py_foo2 == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.foo2");
+               return false;
+       }
        r->in.foo2 = talloc_ptrtype(r, r->in.foo2);
+       if (py_foo2 == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.foo2");
+               return false;
+       }
        PY_CHECK_TYPE(&echo_Enum2_Type, py_foo2, return false;);
        if (talloc_reference(r, pytalloc_get_mem_ctx(py_foo2)) == NULL) {
                PyErr_NoMemory();
                return false;
        }
        r->in.foo2 = (struct echo_Enum2 *)pytalloc_get_ptr(py_foo2);
+       if (py_foo3 == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.foo3");
+               return false;
+       }
        r->in.foo3 = talloc_ptrtype(r, r->in.foo3);
+       if (py_foo3 == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.foo3");
+               return false;
+       }
        {
                union echo_Enum3 *foo3_switch_1;
                foo3_switch_1 = py_export_echo_Enum3(r, *r->in.foo1, py_foo3);
@@ -1611,7 +1861,15 @@ static bool pack_py_echo_TestSurrounding_args_in(PyObject *args, PyObject *kwarg
                return false;
        }
 
+       if (py_data == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.data");
+               return false;
+       }
        r->in.data = talloc_ptrtype(r, r->in.data);
+       if (py_data == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.data");
+               return false;
+       }
        PY_CHECK_TYPE(&echo_Surrounding_Type, py_data, return false;);
        if (talloc_reference(r, pytalloc_get_mem_ctx(py_data)) == NULL) {
                PyErr_NoMemory();
@@ -1641,15 +1899,31 @@ static bool pack_py_echo_TestDoublePointer_args_in(PyObject *args, PyObject *kwa
                return false;
        }
 
+       if (py_data == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.data");
+               return false;
+       }
        r->in.data = talloc_ptrtype(r, r->in.data);
+       if (py_data == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.data");
+               return false;
+       }
        if (py_data == Py_None) {
                *r->in.data = NULL;
        } else {
                *r->in.data = NULL;
+               if (py_data == NULL) {
+                       PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct **r->in.data");
+                       return false;
+               }
                if (py_data == Py_None) {
                        **r->in.data = NULL;
                } else {
                        **r->in.data = talloc_ptrtype(r, **r->in.data);
+                       if (py_data == NULL) {
+                               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ***r->in.data");
+                               return false;
+                       }
                        {
                                const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(***r->in.data));
                                if (PyLong_Check(py_data)) {
@@ -1733,7 +2007,6 @@ static PyObject *syntax_rpcecho_new(PyTypeObject *type, PyObject *args, PyObject
 static PyTypeObject rpcecho_SyntaxType = {
        PyObject_HEAD_INIT(NULL) 0,
        .tp_name = "echo.rpcecho",
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_doc = "abstract_syntax()\n"PY_DOC_RPCECHO_SYNTAX,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        .tp_new = syntax_rpcecho_new,
@@ -1762,8 +2035,8 @@ void initecho(void)
        if (dep_samba_dcerpc_misc == NULL)
                return;
 
-       Object_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "Object");
-       if (Object_Type == NULL)
+       BaseObject_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "BaseObject");
+       if (BaseObject_Type == NULL)
                return;
 
        ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
@@ -1774,27 +2047,37 @@ void initecho(void)
        if (ndr_syntax_id_Type == NULL)
                return;
 
-       echo_info1_Type.tp_base = Object_Type;
+       echo_info1_Type.tp_base = BaseObject_Type;
+       echo_info1_Type.tp_basicsize = pytalloc_BaseObject_size();
 
-       echo_info2_Type.tp_base = Object_Type;
+       echo_info2_Type.tp_base = BaseObject_Type;
+       echo_info2_Type.tp_basicsize = pytalloc_BaseObject_size();
 
-       echo_info3_Type.tp_base = Object_Type;
+       echo_info3_Type.tp_base = BaseObject_Type;
+       echo_info3_Type.tp_basicsize = pytalloc_BaseObject_size();
 
-       echo_info4_Type.tp_base = Object_Type;
+       echo_info4_Type.tp_base = BaseObject_Type;
+       echo_info4_Type.tp_basicsize = pytalloc_BaseObject_size();
 
-       echo_info5_Type.tp_base = Object_Type;
+       echo_info5_Type.tp_base = BaseObject_Type;
+       echo_info5_Type.tp_basicsize = pytalloc_BaseObject_size();
 
-       echo_info6_Type.tp_base = Object_Type;
+       echo_info6_Type.tp_base = BaseObject_Type;
+       echo_info6_Type.tp_basicsize = pytalloc_BaseObject_size();
 
-       echo_info7_Type.tp_base = Object_Type;
+       echo_info7_Type.tp_base = BaseObject_Type;
+       echo_info7_Type.tp_basicsize = pytalloc_BaseObject_size();
 
-       echo_Enum2_Type.tp_base = Object_Type;
+       echo_Enum2_Type.tp_base = BaseObject_Type;
+       echo_Enum2_Type.tp_basicsize = pytalloc_BaseObject_size();
 
-       echo_Surrounding_Type.tp_base = Object_Type;
+       echo_Surrounding_Type.tp_base = BaseObject_Type;
+       echo_Surrounding_Type.tp_basicsize = pytalloc_BaseObject_size();
 
        rpcecho_InterfaceType.tp_base = ClientConnection_Type;
 
        rpcecho_SyntaxType.tp_base = ndr_syntax_id_Type;
+       rpcecho_SyntaxType.tp_basicsize = pytalloc_BaseObject_size();
 
        if (PyType_Ready(&echo_info1_Type) < 0)
                return;