From fa726d34ada06403728e0c4561f7ab5b61eb68d8 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Sat, 28 Jan 2006 03:26:11 +0000 Subject: [PATCH] add support for 'old' tuple output git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8583 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyrun.swg | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 19ca3dde8..5a48cec2f 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -130,6 +130,7 @@ SWIG_Py_Void(void) SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { +#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { @@ -145,6 +146,29 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { Py_DECREF(obj); } return result; +#else + PyObject* o2; + PyObject* o3; + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyTuple_Check(result)) { + o2 = result; + result = PyTuple_New(1); + PyTuple_SET_ITEM(result, 0, o2); + } + o3 = PyTuple_New(1); + PyTuple_SET_ITEM(o3, 0, obj); + o2 = result; + result = PySequence_Concat(o2, o3); + Py_DECREF(o2); + Py_DECREF(o3); + } + return result; +#endif } SWIGINTERN int