It is a wierd problem that sometimes happens when I use SWIG to generate a Python wrappers. It happens with both Swig 2.x and 3.x versions. I don't know what triggers it, but sometimes after code refactoring, this error appears.
The problem is that SWIG generates code that is not valid Python, but some kind of pseudo-code. For example
class SwigPyIterator(_object):
... note that method definitions are not Python:
def value(self) -> "PyObject *" : return _vabamorf.SwigPyIterator_value(self)
def incr(self, n : 'size_t'=1) -> "swig::SwigPyIterator *" : return _vabamorf.SwigPyIterator_incr(self, n)
def decr(self, n : 'size_t'=1) -> "swig::SwigPyIterator *" : return _vabamorf.SwigPyIterator_decr(self, n)
I am using setuptools and here are the lines relevant to SWIG:
swigging estnltk/pyvabamorf/vabamorf.i to estnltk/pyvabamorf/vabamorf_wrap.cpp
swig -python -c++ -py3 -o estnltk/pyvabamorf/vabamorf_wrap.cpp estnltk/pyvabamorf/vabamorf.i
Does anyone know, what triggers this behaviour and how to fix it? I have been able to fix this in the past, but I have never been able to trace down specific changes that made this problem disappear.