Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix Py_None reference count. #272

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions graphlearn/python/c/py_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ PyObject* get_dag_value(GetDagValuesResponse* res,
auto t = res->GetValue(node_id, key);
auto values = std::get<0>(t);
if (values == nullptr) {
Py_INCREF(Py_None); // 增加None的引用计数,以防止Python回收它
return Py_None;
baoleai marked this conversation as resolved.
Show resolved Hide resolved
}
int32_t size = values->Size();
Expand Down Expand Up @@ -713,10 +714,12 @@ PyObject* get_dag_value_indice(GetDagValuesResponse* res,
auto t = res->GetValue(node_id, key);
auto indices = std::get<1>(t);
if (indices == nullptr) {
Py_INCREF(Py_None); // 增加None的引用计数,以防止Python回收它
return Py_None;
}
int32_t size = indices->Size();
if (size == 0) {
Py_INCREF(Py_None); // 增加None的引用计数,以防止Python回收它
return Py_None;
}
npy_intp shape[1];
Expand Down
Loading