summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/python/pypgf.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/runtime/python/pypgf.c b/src/runtime/python/pypgf.c
index 732c14e69..93dd0d034 100644
--- a/src/runtime/python/pypgf.c
+++ b/src/runtime/python/pypgf.c
@@ -2619,6 +2619,24 @@ PGF_dealloc(PGFObject* self)
Py_TYPE(self)->tp_free((PyObject*)self);
}
+static PyObject *
+PGF_repr(PGFObject *self)
+{
+ GuPool* tmp_pool = gu_local_pool();
+
+ GuExn* err = gu_exn(tmp_pool);
+ GuStringBuf* sbuf = gu_new_string_buf(tmp_pool);
+ GuOut* out = gu_string_buf_out(sbuf);
+
+ pgf_print(self->pgf, out, err);
+
+ PyObject* pystr = PyString_FromStringAndSize(gu_string_buf_data(sbuf),
+ gu_string_buf_length(sbuf));
+
+ gu_pool_free(tmp_pool);
+ return pystr;
+}
+
static PyObject*
PGF_getAbstractName(PGFObject *self, void *closure)
{
@@ -3239,7 +3257,7 @@ static PyTypeObject pgf_PGFType = {
0, /*tp_as_mapping*/
0, /*tp_hash */
0, /*tp_call*/
- 0, /*tp_str*/
+ (reprfunc) PGF_repr, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/