我正在尝试升级:从SWIG 2.0.11和Python 2.7.12到SWIG 3.0.12和Python 3.6,但是当我在任何迭代器上运行测试时(使用%template自动生成),我得到了下面的异常:
SystemError: <built-in function xxx_iterator> returned a result with an error set
例如,即使最简单的迭代也会失败:
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
有什么想法吗?
同样,这在SWIG 2.0.11和Python 2.7.12中也能很好地工作....
编辑:添加更简单的示例:
它可以是ANY %模板生成的迭代器,例如,在.i文件中定义的以下模板:
%template(Ints) std::list<int>;
使用以下简单代码时将失败:
intsList = ncore.Ints()
intsList.append(1)
intsList.append(2)
for i in intsList:
print(i)
并显示类似以下的消息:
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
2条答案
按热度按时间qoefvg9y1#
这很奇怪,只是从头开始重新编译了所有内容。然后我测试了您的简化示例(如果理解正确的话):
我的测试:
编译步骤:
然后,在将mytest模块导入到python之后,一切都像魔咒一样工作。
测试配置:
iyzzxitl2#
虽然这是一个比较老的问题,但最近我在CentOS7 docker中处理SELinux和setools时遇到了类似的问题(
<built-in function delete_qpol_iterator_t> returned a result with an error set
),从source code构建和安装libsepol和libselinux可能会解决这个问题。因此,我想更新相关的库和其他依赖项可能是有用的。