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