The branch, master has been updated
       via  2170f55 pidl:Python: use of pytalloc_GenericObject_reference*() for 
pyrpc_{ex,im}port_union() wrapping
       via  1ee0c0f pidl:Python: replace pytalloc_CObject_FromTallocPtr() with 
pytalloc_GenericObject_reference_ex()
       via  d62eb3c pidl:Python: make sure print HASH references for STRUCT 
types
       via  8b2b721 py_net: make use of pytalloc_GenericObject_steal()
       via  2005754 talloc: version 2.1.9
       via  2cae14d pytalloc: add 
pytalloc_GenericObject_{steal,reference}[_ex]()
      from  7318097 s3/smbd: allow GET_DFS_REFERRAL fsctl on any smb2 connexion

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 2170f556299c6ab4ce33f22169ca26ecad3440e3
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Feb 20 18:02:09 2017 +0100

    pidl:Python: use of pytalloc_GenericObject_reference*() for 
pyrpc_{ex,im}port_union() wrapping
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12601
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abart...@samba.org>
    Autobuild-Date(master): Sat Feb 25 06:33:33 CET 2017 on sn-devel-144

commit 1ee0c0f8280393c708f23361ebcba0776e8b4d33
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Feb 22 09:07:54 2017 +0100

    pidl:Python: replace pytalloc_CObject_FromTallocPtr() with 
pytalloc_GenericObject_reference_ex()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12601
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit d62eb3cc9f97b203d21ec6e75c48c739a43bc163
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Feb 22 10:08:46 2017 +0100

    pidl:Python: make sure print HASH references for STRUCT types
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12601
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 8b2b721208dd0b05595d50851f0e13486e0b915f
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Feb 22 10:14:10 2017 +0100

    py_net: make use of pytalloc_GenericObject_steal()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12601
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 20057544cb9be5a18141476739744d1f1af7cde9
Author: Stefan Metzmacher <me...@samba.org>
Date:   Wed Feb 22 08:00:10 2017 +0100

    talloc: version 2.1.9
    
    * fix some coverity defects
    * fix TALLOC_VERSION_MINOR and talloc_version_minor()
    * add new tests
    * add pytalloc_get_type()
    * add pytalloc_GenericObject_{steal,reference}[_ex]()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 2cae14df12491c407a858cb3b4f582e2a2626319
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Feb 20 17:33:42 2017 +0100

    pytalloc: add pytalloc_GenericObject_{steal,reference}[_ex]()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 ...oc-util-2.1.7.sigs => pytalloc-util-2.1.9.sigs} |   3 +
 ...til-2.1.7.sigs => pytalloc-util.py3-2.1.9.sigs} |   4 +-
 .../ABI/{talloc-2.1.4.sigs => talloc-2.1.9.sigs}   |   0
 lib/talloc/pytalloc.c                              |  13 +++
 lib/talloc/pytalloc.h                              |  28 ++++-
 lib/talloc/pytalloc_guide.txt                      |  73 +++++++++++--
 lib/talloc/pytalloc_util.c                         |  95 ++++++++++++++++-
 lib/talloc/wscript                                 |   2 +-
 pidl/lib/Parse/Pidl/Samba4/Python.pm               | 113 +++++----------------
 source4/libnet/py_net.c                            |   5 +-
 source4/librpc/rpc/pyrpc_util.c                    |  44 +-------
 11 files changed, 235 insertions(+), 145 deletions(-)
 copy lib/talloc/ABI/{pytalloc-util-2.1.7.sigs => pytalloc-util-2.1.9.sigs} 
(77%)
 copy lib/talloc/ABI/{pytalloc-util-2.1.7.sigs => pytalloc-util.py3-2.1.9.sigs} 
(75%)
 copy lib/talloc/ABI/{talloc-2.1.4.sigs => talloc-2.1.9.sigs} (100%)


Changeset truncated at 500 lines:

diff --git a/lib/talloc/ABI/pytalloc-util-2.1.7.sigs 
b/lib/talloc/ABI/pytalloc-util-2.1.9.sigs
similarity index 77%
copy from lib/talloc/ABI/pytalloc-util-2.1.7.sigs
copy to lib/talloc/ABI/pytalloc-util-2.1.9.sigs
index 666fec0..9d4d4d1 100644
--- a/lib/talloc/ABI/pytalloc-util-2.1.7.sigs
+++ b/lib/talloc/ABI/pytalloc-util-2.1.9.sigs
@@ -1,3 +1,4 @@
+_pytalloc_check_type: int (PyObject *, const char *)
 _pytalloc_get_mem_ctx: TALLOC_CTX *(PyObject *)
 _pytalloc_get_ptr: void *(PyObject *)
 _pytalloc_get_type: void *(PyObject *, const char *)
@@ -6,6 +7,8 @@ pytalloc_BaseObject_check: int (PyObject *)
 pytalloc_BaseObject_size: size_t (void)
 pytalloc_CObject_FromTallocPtr: PyObject *(void *)
 pytalloc_Check: int (PyObject *)
+pytalloc_GenericObject_reference_ex: PyObject *(TALLOC_CTX *, void *)
+pytalloc_GenericObject_steal_ex: PyObject *(TALLOC_CTX *, void *)
 pytalloc_GetBaseObjectType: PyTypeObject *(void)
 pytalloc_GetObjectType: PyTypeObject *(void)
 pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
diff --git a/lib/talloc/ABI/pytalloc-util-2.1.7.sigs 
b/lib/talloc/ABI/pytalloc-util.py3-2.1.9.sigs
similarity index 75%
copy from lib/talloc/ABI/pytalloc-util-2.1.7.sigs
copy to lib/talloc/ABI/pytalloc-util.py3-2.1.9.sigs
index 666fec0..62f066f 100644
--- a/lib/talloc/ABI/pytalloc-util-2.1.7.sigs
+++ b/lib/talloc/ABI/pytalloc-util.py3-2.1.9.sigs
@@ -1,11 +1,13 @@
+_pytalloc_check_type: int (PyObject *, const char *)
 _pytalloc_get_mem_ctx: TALLOC_CTX *(PyObject *)
 _pytalloc_get_ptr: void *(PyObject *)
 _pytalloc_get_type: void *(PyObject *, const char *)
 pytalloc_BaseObject_PyType_Ready: int (PyTypeObject *)
 pytalloc_BaseObject_check: int (PyObject *)
 pytalloc_BaseObject_size: size_t (void)
-pytalloc_CObject_FromTallocPtr: PyObject *(void *)
 pytalloc_Check: int (PyObject *)
+pytalloc_GenericObject_reference_ex: PyObject *(TALLOC_CTX *, void *)
+pytalloc_GenericObject_steal_ex: PyObject *(TALLOC_CTX *, void *)
 pytalloc_GetBaseObjectType: PyTypeObject *(void)
 pytalloc_GetObjectType: PyTypeObject *(void)
 pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
diff --git a/lib/talloc/ABI/talloc-2.1.4.sigs b/lib/talloc/ABI/talloc-2.1.9.sigs
similarity index 100%
copy from lib/talloc/ABI/talloc-2.1.4.sigs
copy to lib/talloc/ABI/talloc-2.1.9.sigs
diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c
index 2039528..3532fdf 100644
--- a/lib/talloc/pytalloc.c
+++ b/lib/talloc/pytalloc.c
@@ -238,6 +238,14 @@ static PyTypeObject TallocBaseObject_Type = {
 #endif
 };
 
+static PyTypeObject TallocGenericObject_Type = {
+       .tp_name = "talloc.GenericObject",
+       .tp_doc = "Python wrapper for a talloc-maintained object.",
+       .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+       .tp_base = &TallocBaseObject_Type,
+       .tp_basicsize = sizeof(pytalloc_BaseObject),
+};
+
 #define MODULE_DOC PyDoc_STR("Python wrapping of talloc-maintained objects.")
 
 #if PY_MAJOR_VERSION >= 3
@@ -261,6 +269,9 @@ static PyObject *module_init(void)
        if (PyType_Ready(&TallocBaseObject_Type) < 0)
                return NULL;
 
+       if (PyType_Ready(&TallocGenericObject_Type) < 0)
+               return NULL;
+
 #if PY_MAJOR_VERSION >= 3
        m = PyModule_Create(&moduledef);
 #else
@@ -273,6 +284,8 @@ static PyObject *module_init(void)
        PyModule_AddObject(m, "Object", (PyObject *)&TallocObject_Type);
        Py_INCREF(&TallocBaseObject_Type);
        PyModule_AddObject(m, "BaseObject", (PyObject *)&TallocBaseObject_Type);
+       Py_INCREF(&TallocGenericObject_Type);
+       PyModule_AddObject(m, "GenericObject", (PyObject 
*)&TallocGenericObject_Type);
        return m;
 }
 
diff --git a/lib/talloc/pytalloc.h b/lib/talloc/pytalloc.h
index 6a0ac18..11653bf 100644
--- a/lib/talloc/pytalloc.h
+++ b/lib/talloc/pytalloc.h
@@ -40,6 +40,10 @@ int pytalloc_Check(PyObject *);
 
 int pytalloc_BaseObject_check(PyObject *);
 
+int _pytalloc_check_type(PyObject *py_obj, const char *type_name);
+#define pytalloc_check_type(py_obj, type) \
+       _pytalloc_check_type((PyObject *)(py_obj), #type)
+
 /* Retrieve the pointer for a pytalloc_object. Like talloc_get_type() 
  * but for pytalloc_Objects. */
 void *_pytalloc_get_type(PyObject *py_obj, const char *type_name);
@@ -58,8 +62,30 @@ PyObject *pytalloc_reference_ex(PyTypeObject *py_type, 
TALLOC_CTX *mem_ctx, void
 #define pytalloc_new(type, typeobj) pytalloc_steal(typeobj, talloc_zero(NULL, 
type))
 
 #if PY_MAJOR_VERSION < 3
-PyObject *pytalloc_CObject_FromTallocPtr(void *);
+/*
+ * Don't use this anymore! Use pytalloc_GenericObject_steal()
+ * or pytalloc_GenericObject_reference().
+ */
+#ifndef _DEPRECATED_
+#ifdef HAVE___ATTRIBUTE__
+#define _DEPRECATED_ __attribute__ ((deprecated))
+#else
+#define _DEPRECATED_
+#endif
 #endif
+PyObject *pytalloc_CObject_FromTallocPtr(void *) _DEPRECATED_;
+#endif
+
+/*
+ * Wrap a generic talloc pointer into a talloc.GenericObject,
+ * this is a subclass of talloc.BaseObject.
+ */
+PyObject *pytalloc_GenericObject_steal_ex(TALLOC_CTX *mem_ctx, void *ptr);
+#define pytalloc_GenericObject_steal(talloc_ptr) \
+       pytalloc_GenericObject_steal_ex(talloc_ptr, talloc_ptr)
+PyObject *pytalloc_GenericObject_reference_ex(TALLOC_CTX *mem_ctx, void *ptr);
+#define pytalloc_GenericObject_reference(talloc_ptr) \
+       pytalloc_GenericObject_reference_ex(talloc_ptr, talloc_ptr)
 
 size_t pytalloc_BaseObject_size(void);
 
diff --git a/lib/talloc/pytalloc_guide.txt b/lib/talloc/pytalloc_guide.txt
index 962d449..bd2b68c 100644
--- a/lib/talloc/pytalloc_guide.txt
+++ b/lib/talloc/pytalloc_guide.txt
@@ -92,6 +92,15 @@ Check whether a specific object is a talloc BaseObject. 
Returns non-zero if it i
 a pytalloc_BaseObject and zero otherwise.
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+int pytalloc_check_type(PyObject *py_obj, type)
+
+Check if the object based on `pytalloc_*Object` py_obj. type should be a
+C type, similar to a type passed to `talloc_get_type`.
+This can be used as a check before using pytalloc_get_type()
+or an alternative codepath. Returns non-zero if it is
+an object of the expected type and zero otherwise.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 type *pytalloc_get_type(PyObject *py_obj, type)
 
 Retrieve the pointer from a `pytalloc_Object` py_obj. type should be a
@@ -113,7 +122,9 @@ Retrieve the talloc context associated with a 
pytalloc_Object or pytalloc_BaseOb
 PyObject *pytalloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void 
*ptr)
 
 Create a new Python wrapping object for a talloc pointer and context, with
-py_type as associated Python sub type object.
+py_type as associated Python sub type object. This typically used
+when `mem_ctx` and `ptr` differ, e.g. a pointer to an array element.
+`pytalloc_get_ptr()` can be used to get the pointer out of the object again.
 
 This will *not* increment the reference counter for the talloc context,
 so the caller should make sure such an increment has happened. When the Python
@@ -123,7 +134,9 @@ object goes away, it will unreference the talloc context.
 PyObject *pytalloc_steal(PyTypeObject *py_type, void *ptr)
 
 Create a new Python wrapping object for a talloc pointer and context, with
-py_type as associated Python sub type object.
+py_type as associated Python sub type object. The pointer will also be used
+as the talloc context. `pytalloc_get_type()` can be used to get
+the pointer out of the object again.
 
 This will *not* increment the reference counter for the talloc context,
 so the caller should make sure such an increment has happened. When the Python
@@ -133,7 +146,9 @@ object goes away, it will unreference the talloc context.
 PyObject *pytalloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, 
void *ptr)
 
 Create a new Python wrapping object for a talloc pointer and context, with
-py_type as associated Python sub type object.
+py_type as associated Python sub type object. This typically used
+when `mem_ctx` and `ptr` differ, e.g. a pointer to an array element.
+`pytalloc_get_ptr()` can be used to get the pointer out of the object again.
 
 This will increment the reference counter for the talloc context.
 
@@ -142,7 +157,8 @@ PyObject *pytalloc_reference(PyTypeObject *py_type, void 
*talloc_ptr)
 
 Create a new Python wrapping object for a talloc pointer, with
 py_type as associated Python sub type object. The pointer will also be used
-as the talloc context.
+as the talloc context. `pytalloc_get_type()` can be used to get
+the pointer out of the object again.
 
 This will increment the reference counter for the talloc context.
 
@@ -153,14 +169,59 @@ Create a new, empty pytalloc_Object with the specified 
Python type object. type
 should be a C type, similar to talloc_new().
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-PyObject *pytalloc_CObject_FromTallocPtr(void *);
+PyObject *pytalloc_GenericObject_steal_ex(void *ptr)
+
+Create a new Python wrapping object for a generic talloc pointer,
+as sub type of `pytalloc_BaseObject`. This typically used
+when `mem_ctx` and `ptr` differ, e.g. a pointer to an array element.
+`pytalloc_get_ptr()` can be used to get the pointer out of the object again.
+
+This will *not* increment the reference counter for the talloc context,
+so the caller should make sure such an increment has happened. When the Python
+object goes away, it will unreference the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_GenericObject_steal(void *ptr)
+
+Create a new Python wrapping object for a generic talloc pointer,
+as sub type of `pytalloc_BaseObject`. The pointer will also be used
+as the talloc context. `pytalloc_get_type()` can be used to get
+the pointer out of the object again.
+
+This will *not* increment the reference counter for the talloc context,
+so the caller should make sure such an increment has happened. When the Python
+object goes away, it will unreference the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_GenericObject_reference_ex(void *ptr)
+
+Create a new Python wrapping object for a generic talloc pointer,
+as sub type of `pytalloc_BaseObject`. This typically used
+when `mem_ctx` and `ptr` differ, e.g. a pointer to an array element.
+`pytalloc_get_ptr()` can be used to get the pointer out of the object again.
+
+This will increment the reference counter for the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+PyObject *pytalloc_GenericObject_reference(void *ptr)
+
+Create a new Python wrapping object for a generic talloc pointer,
+as sub type of `pytalloc_BaseObject`. The pointer will also be used
+as the talloc context. `pytalloc_get_type()` can be used to get
+the pointer out of the object again.
+
+This will increment the reference counter for the talloc context.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+DEPRECATED! PyObject *pytalloc_CObject_FromTallocPtr(void *);
 
 Create a new pytalloc_Object for an abitrary talloc-maintained C pointer. This 
will
 use a generic VoidPtr Python type, which just provides an opaque object in
 Python. The caller is responsible for incrementing the talloc reference count 
before calling
 this function - it will dereference the talloc pointer when it is garbage 
collected.
 
-This function is only available on Python 2.
+This function is deprecated and only available on Python 2.
+Use pytalloc_GenericObject_{reference,steal}[_ex]() instead.
 
 Debug function for talloc in Python
 -----------------------------------
diff --git a/lib/talloc/pytalloc_util.c b/lib/talloc/pytalloc_util.c
index cb71dc9..923fe5d 100644
--- a/lib/talloc/pytalloc_util.c
+++ b/lib/talloc/pytalloc_util.c
@@ -64,6 +64,26 @@ _PUBLIC_ PyTypeObject *pytalloc_GetBaseObjectType(void)
        return type;
 }
 
+static PyTypeObject *pytalloc_GetGenericObjectType(void)
+{
+       static PyTypeObject *type = NULL;
+       PyObject *mod;
+
+       if (type != NULL) {
+               return type;
+       }
+
+       mod = PyImport_ImportModule("talloc");
+       if (mod == NULL) {
+               return NULL;
+       }
+
+       type = (PyTypeObject *)PyObject_GetAttrString(mod, "GenericObject");
+       Py_DECREF(mod);
+
+       return type;
+}
+
 /**
  * Import an existing talloc pointer into a Python object.
  */
@@ -204,6 +224,26 @@ _PUBLIC_ PyObject *pytalloc_CObject_FromTallocPtr(void 
*ptr)
 
 #endif
 
+/*
+ * Wrap a generic talloc pointer into a talloc.GenericObject,
+ * this is a subclass of talloc.BaseObject.
+ */
+_PUBLIC_ PyObject *pytalloc_GenericObject_steal_ex(TALLOC_CTX *mem_ctx, void 
*ptr)
+{
+       PyTypeObject *tp = pytalloc_GetGenericObjectType();
+       return pytalloc_steal_ex(tp, mem_ctx, ptr);
+}
+
+/*
+ * Wrap a generic talloc pointer into a talloc.GenericObject,
+ * this is a subclass of talloc.BaseObject.
+ */
+_PUBLIC_ PyObject *pytalloc_GenericObject_reference_ex(TALLOC_CTX *mem_ctx, 
void *ptr)
+{
+       PyTypeObject *tp = pytalloc_GetGenericObjectType();
+       return pytalloc_reference_ex(tp, mem_ctx, ptr);
+}
+
 _PUBLIC_ int pytalloc_Check(PyObject *obj)
 {
        PyTypeObject *tp = pytalloc_GetObjectType();
@@ -223,21 +263,66 @@ _PUBLIC_ size_t pytalloc_BaseObject_size(void)
        return sizeof(pytalloc_BaseObject);
 }
 
-_PUBLIC_ void *_pytalloc_get_type(PyObject *py_obj, const char *type_name)
+static void *_pytalloc_get_checked_type(PyObject *py_obj, const char 
*type_name,
+                                       bool check_only, const char *function)
 {
-       void *ptr = _pytalloc_get_ptr(py_obj);
+       TALLOC_CTX *mem_ctx;
+       void *ptr = NULL;
        void *type_obj = talloc_check_name(ptr, type_name);
 
+       mem_ctx = _pytalloc_get_mem_ctx(py_obj);
+       ptr = _pytalloc_get_ptr(py_obj);
+
+       if (mem_ctx != ptr) {
+               if (check_only) {
+                       return NULL;
+               }
+
+               PyErr_Format(PyExc_TypeError, "%s: expected %s, "
+                            "but the pointer is no talloc pointer, "
+                            "pytalloc_get_ptr() would get the raw pointer.",
+                            function, type_name);
+               return NULL;
+       }
+
+       type_obj = talloc_check_name(ptr, type_name);
        if (type_obj == NULL) {
-               const char *name = talloc_get_name(ptr);
-               PyErr_Format(PyExc_TypeError, "pytalloc: expected %s, got %s",
-                            type_name, name);
+               const char *name = NULL;
+
+               if (check_only) {
+                       return NULL;
+               }
+
+               name = talloc_get_name(ptr);
+               PyErr_Format(PyExc_TypeError, "%s: expected %s, got %s",
+                            function, type_name, name);
                return NULL;
        }
 
        return ptr;
 }
 
+_PUBLIC_ int _pytalloc_check_type(PyObject *py_obj, const char *type_name)
+{
+       void *ptr = NULL;
+
+       ptr = _pytalloc_get_checked_type(py_obj, type_name,
+                                        true, /* check_only */
+                                        "pytalloc_check_type");
+       if (ptr == NULL) {
+               return 0;
+       }
+
+       return 1;
+}
+
+_PUBLIC_ void *_pytalloc_get_type(PyObject *py_obj, const char *type_name)
+{
+       return _pytalloc_get_checked_type(py_obj, type_name,
+                                         false, /* not check_only */
+                                         "pytalloc_get_type");
+}
+
 _PUBLIC_ void *_pytalloc_get_ptr(PyObject *py_obj)
 {
        if (pytalloc_BaseObject_check(py_obj)) {
diff --git a/lib/talloc/wscript b/lib/talloc/wscript
index d77de26..7f9bad7 100644
--- a/lib/talloc/wscript
+++ b/lib/talloc/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'talloc'
-VERSION = '2.1.8'
+VERSION = '2.1.9'
 
 
 blddir = 'bin'
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm 
b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 5edf96c..f871e04 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -245,12 +245,18 @@ sub PythonStruct($$$$$$)
                $self->pidl("static PyGetSetDef ".$getsetters."[] = {");
                $self->indent;
                foreach my $e (@{$d->{ELEMENTS}}) {
+                       my $etype = "";
+                       if (ref($e->{TYPE}) eq "HASH") {
+                               $etype = $e->{TYPE}->{NAME};
+                       } else {
+                               $etype = $e->{TYPE};
+                       }
                        $self->pidl("{");
                        $self->indent;
                        $self->pidl(".name = discard_const_p(char, 
\"$e->{NAME}\"),");
                        $self->pidl(".get = py_$name\_get_$e->{NAME},");
                        $self->pidl(".set = py_$name\_set_$e->{NAME},");
-                       $self->pidl(".doc = discard_const_p(char, 
\"PIDL-generated element of base type $e->{TYPE}\")");
+                       $self->pidl(".doc = discard_const_p(char, 
\"PIDL-generated element of base type $etype\")");
                        $self->deindent;
                        $self->pidl("},");
                }
@@ -1175,29 +1181,15 @@ sub PythonType($$$$)
                my $py_methods = "NULL";
                my $typename = mapTypeName($d);
 
-               ##
-               ## PyCapsule (starting with 2.7) vs. PyCObject (up to 3.2)
-               ##
-               ## As we need to support python 2.6, we can't use PyCapsule yet.
-               ##
-               ## When we'll get support fpr Python3 we'll have to emulate
-               ## PyCObject using PyCapsule and convert these functions to
-               ## use PyCapsule.
-               ##
                $self->pidl("static PyObject 
*py_$d->{NAME}\_import(PyTypeObject *type, PyObject *args, PyObject *kwargs)");
                $self->pidl("{");
                $self->indent;
                $self->pidl("const char * const kwnames[] = { \"mem_ctx\", 
\"level\", \"in\", NULL };");
                $self->pidl("PyObject *mem_ctx_obj = NULL;");
-               $self->pidl("static const char *mem_ctx_type = 
\"TALLOC_CTX\";");
-               $self->pidl("const char *mem_ctx_desc = NULL;");
                $self->pidl("TALLOC_CTX *mem_ctx = NULL;");
                $self->pidl("int level = 0;");
                $self->pidl("PyObject *in_obj = NULL;");
-               $self->pidl("static const char *in_type = \"$typename\";");
-               $self->pidl("const char *in_desc = NULL;");
                $self->pidl("$typename *in = NULL;");
-               $self->pidl("int cmp;");
                $self->pidl("");
                $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
\"OiO:import\",");
                $self->indent;
@@ -1210,54 +1202,20 @@ sub PythonType($$$$)
                $self->pidl("return NULL;");
                $self->deindent;
                $self->pidl("}");
-               $self->pidl("if (!PyCObject_Check(mem_ctx_obj)) {");
-               $self->indent;
-               $self->pidl("PyErr_SetString(PyExc_TypeError, \"mem_ctx needs 
to be of type PyCObject!\");");
-               $self->pidl("return NULL;");
-               $self->deindent;
-               $self->pidl("}");
-               $self->pidl("mem_ctx_desc = (const char 
*)PyCObject_GetDesc(mem_ctx_obj);");
-               $self->indent;
-               $self->pidl("if (mem_ctx_desc == NULL) {");
-               $self->pidl("PyErr_SetString(PyExc_TypeError, \"mem_ctx hash no 
PyCObject_GetDesc()!\");");
-               $self->pidl("return NULL;");
-               $self->deindent;
-               $self->pidl("}");
-               $self->pidl("cmp = strncmp(mem_ctx_type, mem_ctx_desc, 
strlen(mem_ctx_type) + 1);");
-               $self->pidl("if (cmp != 0) {");
-               $self->indent;
-               $self->pidl("PyErr_Format(PyExc_TypeError, \"mem_ctx should 
have PyCObject_GetDesc() = %s!\", mem_ctx_type);");
-               $self->pidl("return NULL;");
-               $self->deindent;
-               $self->pidl("}");
-               $self->pidl("mem_ctx = PyCObject_AsVoidPtr(mem_ctx_obj);");
+               $self->pidl("mem_ctx = pytalloc_get_ptr(mem_ctx_obj);");
                $self->pidl("if (mem_ctx == NULL) {");
                $self->indent;
                $self->pidl("PyErr_SetString(PyExc_TypeError, \"mem_ctx is 
NULL)!\");");
                $self->pidl("return NULL;");
                $self->deindent;
                $self->pidl("}");
-               $self->pidl("if (!PyCObject_Check(in_obj)) {");
-               $self->indent;
-               $self->pidl("PyErr_SetString(PyExc_TypeError, \"in needs to be 
of type PyCObject!\");");
-               $self->pidl("return NULL;");
-               $self->deindent;
-               $self->pidl("}");
-               $self->pidl("in_desc = (const char 
*)PyCObject_GetDesc(in_obj);");
+               $self->pidl("in = ($typename *)pytalloc_get_ptr(in_obj);");
+               $self->pidl("if (in == NULL) {");
                $self->indent;
-               $self->pidl("if (in_desc == NULL) {");
-               $self->pidl("PyErr_SetString(PyExc_TypeError, \"in hash no 
PyCObject_GetDesc()!\");");
+               $self->pidl("PyErr_Format(PyExc_TypeError, \"in needs to be a 
pointer to $typename!\");");
                $self->pidl("return NULL;");


-- 
Samba Shared Repository

Reply via email to