I'm trying to extend a C++ library by implementing the python iteration protocol on a class. The problem is that trying to raise a StopIteration exception from the next() method makes the program SegFault. The method I've used for raising the exception from the C++ code (in python.i) is the one described here: http://www.swig.org/Doc1.3/Python.html#Python_nn44
Although that list doesn't have the StopIteration exception listed this is what I've tried:
PyErr_SetString(PyExc_StopIteration, NULL);