From 23eb236babbad2b0caa385186790b6719d4c84bb Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Mon, 6 Mar 2006 18:36:28 +0000 Subject: [PATCH] fix _swig_repr, as reported by Robin git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8969 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyrun.swg | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 26d181a5b..61f7fb5ca 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -370,14 +370,22 @@ PySwigObject_hex(PySwigObject *v) } SWIGRUNTIME PyObject * +#ifdef METH_NOARGS PySwigObject_repr(PySwigObject *v) +#else +PySwigObject_repr(PySwigObject *v, PyObject *args) +#endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *hex = PySwigObject_hex(v); PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); Py_DECREF(hex); if (v->next) { +#ifdef METH_NOARGS PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); +#else + PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); +#endif PyString_ConcatAndDel(&repr,nrep); } return repr; @@ -386,7 +394,11 @@ PySwigObject_repr(PySwigObject *v) SWIGRUNTIME int PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { +#ifdef METH_NOARGS PyObject *repr = PySwigObject_repr(v); +#else + PyObject *repr = PySwigObject_repr(v, NULL); +#endif if (repr) { fputs(PyString_AsString(repr), fp); Py_DECREF(repr); @@ -563,6 +575,7 @@ swigobject_methods[] = { {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else @@ -573,6 +586,7 @@ swigobject_methods[] = { {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif