Skip to content

Commit

Permalink
Fix: properly handle Py_None reference count. (#272)
Browse files Browse the repository at this point in the history
Use Py_RETURN_NONE to return Py_None
  • Loading branch information
shidianshifen committed Aug 2, 2023
1 parent e4b5090 commit 526e7d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions graphlearn/python/c/py_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ PyObject* get_dag_value(GetDagValuesResponse* res,
auto t = res->GetValue(node_id, key);
auto values = std::get<0>(t);
if (values == nullptr) {
return Py_None;
Py_RETURN_NONE;
}
int32_t size = values->Size();
npy_intp shape[1];
Expand Down Expand Up @@ -713,11 +713,11 @@ PyObject* get_dag_value_indice(GetDagValuesResponse* res,
auto t = res->GetValue(node_id, key);
auto indices = std::get<1>(t);
if (indices == nullptr) {
return Py_None;
Py_RETURN_NONE;
}
int32_t size = indices->Size();
if (size == 0) {
return Py_None;
Py_RETURN_NONE;
}
npy_intp shape[1];
shape[0] = size;
Expand Down

0 comments on commit 526e7d1

Please sign in to comment.