I'm trying to upgrade from: SWIG 2.0.11 and Python 2.7.12 to SWIG 3.0.12 and Python 3.6, but I get the following exception when I run the tests on any iterator (automatically generated using %template):
SystemError: <built-in function xxx_iterator> returned a result with an error set
For example, even the simplest iteration fails:
Traceback (most recent call last):
File "testRender.py", line 459, in testRender
for v in vertices:
File "ncore.py", line 90833, in __iter__
return self.iterator()
File "ncore.py", line 90830, in iterator
return _ncore.Vertices_iterator(self)
SystemError: <built-in function Vertices_iterator> returned a result with an error set
Any ideas?
Again, this was all working great with SWIG 2.0.11 and Python 2.7.12....
Edit: Adding simpler example:
It could be ANY %template-generated iterator, so, for example, this template, defined in the .i file:
%template(Ints) std::list<int>;
will fail when using this simple code:
intsList = ncore.Ints()
intsList.append(1)
intsList.append(2)
for i in intsList:
print(i)
with a message similar to this:
Traceback (most recent call last):
File "testRender.py", line 459, in testRender
for i in intsList:
File "ncore.py", line 90833, in __iter__
return self.iterator()
File "ncore.py", line 90830, in iterator
return _ncore.Ints_iterator(self)
SystemError: <built-in function Ints_iterator> returned a result with an error set
That is strange, just recompiled everything from scratch. Then I tested your simplified example (if understood correctly):
Mytest.i:
%module mytest
%{
#include <list>
using namespace std;
%}
%include "std_list.i"
namespace std {
%template(Ints) list<int>;
}
Compile steps:
swig -Wall -c++ -python -py3 -o mytest_wrap.cpp mytest.i
g++ -c -g -ansi mytest_wrap.cpp -I/usr/local/include/python3.6m/ -fPIC -o mytest_wrap.o
g++ -g -ansi -o _mytest.so mytest_wrap.o -shared
Then, after importing mytest module to python, everything works like a charm.
Tested configurations:
Though it's an old question relatively, but recently I encountered a similar issue ( <built-in function delete_qpol_iterator_t> returned a result with an error set
) while dealing with SELinux and setools in CentOS7 docker. Building and installing libsepol and libselinux from source code might solve the problem.
So I guess updating relevant libs and other dependencies might be useful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.