diff --git a/CHANGES.current b/CHANGES.current index a5f75897a..198c39d42 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.35 (in progress) ============================ +03/21/2008: wsfulton + [Python] Thread safety patch for STL iterators from Abhinandan Jain. + 03/17/2008: mgossage [Lua] Added %luacode feature to add source code into wrappers. Updated documentation to document this. diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg index 980103ee0..e2dfbc3f5 100644 --- a/Lib/python/pyiterators.swg +++ b/Lib/python/pyiterators.swg @@ -6,7 +6,7 @@ * * Implement a python 'output' iterator for Python 2.2 or higher. * - * Users can derive form the PySwigIterator to implemet their + * Users can derive form the PySwigIterator to implement their * own iterators. As an example (real one since we use it for STL/STD * containers), the template PySwigIterator_T does the * implementation for genereic C++ iterators. @@ -57,17 +57,22 @@ namespace swig { // C++ common/needed methods virtual PySwigIterator *copy() const = 0; - PyObject *next() + PyObject *next() { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads PyObject *obj = value(); - incr(); - return obj; + incr(); + SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads + return obj; } PyObject *previous() { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads decr(); - return value(); + PyObject *obj = value(); + SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads + return obj; } PySwigIterator *advance(ptrdiff_t n)