From f7a0ef04f00cd44845bcee0a171e4cc05a545350 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 18:38:12 +0100 Subject: pidl/python: Support repr() for python types. (This used to be commit cf3664594d3540db20d32bc844f18e20abfa0d96) --- source4/scripting/python/pytalloc.c | 10 +++++++++- source4/scripting/python/pytalloc.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c index 55ed56a627..4032ff75a4 100644 --- a/source4/scripting/python/pytalloc.c +++ b/source4/scripting/python/pytalloc.c @@ -22,7 +22,7 @@ void py_talloc_dealloc(PyObject* self) { py_talloc_Object *obj = (py_talloc_Object *)self; - talloc_free(obj->object); + talloc_free(obj->talloc_ptr); PyObject_Del(self); } @@ -32,3 +32,11 @@ PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr) ret->talloc_ptr = talloc_reference(NULL, ptr); return ret; } + +PyObject *py_talloc_default_repr(PyObject *py_obj) +{ + py_talloc_Object *obj = (py_talloc_Object *)py_obj; + + return PyString_FromFormat("", + talloc_get_name(obj->talloc_ptr)); +} diff --git a/source4/scripting/python/pytalloc.h b/source4/scripting/python/pytalloc.h index 93f6b48d82..735829bfcb 100644 --- a/source4/scripting/python/pytalloc.h +++ b/source4/scripting/python/pytalloc.h @@ -40,4 +40,7 @@ void py_talloc_dealloc(PyObject* self); PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr); +/* Sane default implementation of reprfunc. */ +PyObject *py_talloc_default_repr(PyObject *py_obj); + #endif /* _PY_TALLOC_H_ */ -- cgit