[英]NULL result without error in PyObject_Call
I'm currently coding a Python C-Extension to perform some calculations in C instead of Python. 我目前正在编写Python C-Extension,以使用C而不是Python进行一些计算。 It works just fine, I already got some nice results, but the point is, I get the following error:
它工作正常,我已经得到了一些不错的结果,但是关键是,我得到了以下错误:
NULL result without error in PyObject_Call
It occurs sometimes, not always, when I want to create an instance of the "C Python Object" I created. 当我想创建自己创建的“ C Python对象”的实例时,有时(并非总是如此)会发生这种情况。 The call looks something like the following:
调用看起来类似于以下内容:
import c_class
obj = c_class.dummy(arg1, arg2, arg3);
Does anyone have any suggestions? 有没有人有什么建议? I don't know where this error comes from, since it works from time to time.. I'm kind of lost here.
我不知道此错误从何而来,因为它有时会起作用。
When you return NULL
from ac function exposed to python you must set the error message before, since returning NULL
means an error happened. 当您从暴露给python的ac函数返回
NULL
,必须先设置错误消息,因为返回NULL
表示发生了错误。
If an error happened and you are returning NULL
because of that then, use PyErr_SetString()
, if no error happened, then use 如果发生错误,并且您因此而返回
NULL
,请使用PyErr_SetString()
,如果没有错误发生,请使用
Py_RETURN_NONE;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.