From 2e07b5a7e824f950a25c704ff897fec2be97c55d Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 29 Dec 2017 14:17:56 +0000 Subject: [PATCH] python: Show better repr for AS classes Signed-off-by: Michael Tremer --- src/python/as.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/python/as.c b/src/python/as.c index 44b959c..3c74f9e 100644 --- a/src/python/as.c +++ b/src/python/as.c @@ -58,6 +58,16 @@ static int AS_init(ASObject* self, PyObject* args, PyObject* kwargs) { return 0; } +static PyObject* AS_repr(ASObject* self) { + uint32_t number = loc_as_get_number(self->as); + const char* name = loc_as_get_name(self->as); + + if (name) + return PyUnicode_FromFormat("", number, name); + + return PyUnicode_FromFormat("", number); +} + static PyObject* AS_get_number(ASObject* self) { uint32_t number = loc_as_get_number(self->as); @@ -98,4 +108,5 @@ PyTypeObject ASType = { tp_init: (initproc)AS_init, tp_doc: "AS object", tp_getset: AS_getsetters, + tp_repr: (reprfunc)AS_repr, }; -- 2.39.2