talloc: use the system pytalloc-util for python3 as well
[sfrench/samba-autobuild/.git] / lib / talloc / pytalloc.c
index 74349da843dfbf1df5334bf47ab20cc12f748dd7..3532fdf529149ed636b6de351b210f0734f46d92 100644 (file)
@@ -166,7 +166,7 @@ static PyObject *pytalloc_base_default_repr(PyObject *obj)
        pytalloc_BaseObject *talloc_obj = (pytalloc_BaseObject *)obj;
        PyTypeObject *type = (PyTypeObject*)PyObject_Type(obj);
 
-       return PyStr_FromFormat("<%s talloc based object at 0x%p>",
+       return PyStr_FromFormat("<%s talloc based object at %p>",
                                type->tp_name, talloc_obj->ptr);
 }
 
@@ -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;
 }