diff options
Diffstat (limited to 'lib/talloc/pytalloc_util.c')
-rw-r--r-- | lib/talloc/pytalloc_util.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/talloc/pytalloc_util.c b/lib/talloc/pytalloc_util.c index d5ef919bb2..c485cd1ca3 100644 --- a/lib/talloc/pytalloc_util.c +++ b/lib/talloc/pytalloc_util.c @@ -23,6 +23,26 @@ #include "pytalloc.h" #include <assert.h> +static PyTypeObject *Get_TallocType(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, "Object"); + Py_DECREF(mod); + + return type; +} + /** * Simple dealloc for talloc-wrapping PyObjects */ @@ -133,3 +153,10 @@ PyObject *PyString_FromString_check_null(const char *ptr) } return PyString_FromString(ptr); } + +int PyTalloc_Check(PyObject *obj) +{ + PyTypeObject *tp = Get_TallocType(); + + return PyObject_TypeCheck(obj, tp); +} |