系统错误:<builtin function xxx\u iterator>返回了一个错误s的结果

2024-10-01 15:46:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试从以下位置升级: swig2.0.11和Python 2.7.12到 swig3.0.12和python3.6, 但在任何迭代器(使用%template自动生成)上运行测试时,出现以下异常:

SystemError: <built-in function xxx_iterator> returned a result with an error set

例如,即使是最简单的迭代也会失败:

^{pr2}$

有什么想法吗?在

同样,这一切在swig2.0.11和python2.7.12中都很好地工作了。。。。在

编辑:添加更简单的示例:

它可以是任何%template生成的迭代器,因此,例如,在.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

Tags: inpywithlinefunctiontemplateresultfile
1条回答
网友
1楼 · 发布于 2024-10-01 15:46:32

一切都是从零开始重新编译的。然后我测试了你的简化示例(如果理解正确):

我的测试。一:

%module mytest                                                                                             
%{                                                                                                       
    #include <list>
     using namespace std;                                                                                     
%}                                                                                                       

%include "std_list.i"
namespace std {                                                                                          
    %template(Ints) list<int>;                                                           
}   

编译步骤:

^{pr2}$

然后,在将mytest模块导入python之后,一切都像一个符咒。在

测试配置:

  • 停靠的Ubuntu16.04:Python 3.6.1,swig3.0.12,g++5.4。在
  • 停靠的Centos6:python3.6.1,swig3.0.12,g++(4.9.2和4.4.7)

相关问题 更多 >

    热门问题