diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-01-13 18:38:12 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-01-14 19:53:05 +0100 |
commit | f7a0ef04f00cd44845bcee0a171e4cc05a545350 (patch) | |
tree | 4ea0057d4b3b0f983d3777ca0c3aba88ac9dc488 /source4/scripting/python | |
parent | a99dff8660ca2d168523b7264d9208a8a12ca5cc (diff) | |
download | samba-f7a0ef04f00cd44845bcee0a171e4cc05a545350.tar.gz samba-f7a0ef04f00cd44845bcee0a171e4cc05a545350.tar.bz2 samba-f7a0ef04f00cd44845bcee0a171e4cc05a545350.zip |
pidl/python: Support repr() for python types.
(This used to be commit cf3664594d3540db20d32bc844f18e20abfa0d96)
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/pytalloc.c | 10 | ||||
-rw-r--r-- | source4/scripting/python/pytalloc.h | 3 |
2 files changed, 12 insertions, 1 deletions
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: %s>", + 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_ */ |