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
This commit is contained in:
parent
a9bbfd2b72
commit
23eb236bab
1 changed files with 14 additions and 0 deletions
|
|
@ -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("<Swig Object of type '%s' at 0x%s>", 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue