From 8f5e757867d90d097367e2d5f3e056d3b43dc36f Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Tue, 30 Mar 2004 08:05:29 +0000 Subject: [PATCH] fix for old python versions git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5803 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Lib/python/pycontainer.i | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SWIG/Lib/python/pycontainer.i b/SWIG/Lib/python/pycontainer.i index f3bb7a6d4..b2364397e 100644 --- a/SWIG/Lib/python/pycontainer.i +++ b/SWIG/Lib/python/pycontainer.i @@ -13,13 +13,10 @@ /**** The PySequence C++ Wrap ***/ -%{ +%insert(header) %{ #if PY_VERSION_HEX < 0x02000000 #define PySequence_Size PySequence_Length #endif -#if PY_VERSION_HEX < 0x02020000 -#define PyObject_GetIter Py_INCREF -#endif %} %fragment("PySequence_Cont","header", @@ -565,9 +562,13 @@ namespace swigpy for (int j = 0; j < pysize; ++i, ++j) { PyList_SetItem(keyList, j, swigpy::from(i->first)); } +%#if PY_VERSION_HEX >= 0x02020000 PyObject* iter = PyObject_GetIter(keyList); Py_DECREF(keyList); return iter; +%#else + return keyList; +%#endif } } %enddef