Skip to content

Commit

Permalink
Merge pull request #763 from DavidRConnell/update-public-api
Browse files Browse the repository at this point in the history
Update from deprecated PyCObject to PyCapsule
  • Loading branch information
ntamas authored Mar 7, 2024
2 parents 055e836 + 1741af4 commit ecfced6
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/_igraph/igraphmodule_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,8 @@ extern "C" {

/* Return -1 and set exception on error, 0 on success */
static int import_igraph(void) {
PyObject *c_api_object;
PyObject *module;

module = PyImport_ImportModule("igraph._igraph");
if (module == 0)
return -1;

c_api_object = PyObject_GetAttrString(module, "_C_API");
if (c_api_object == 0) {
Py_DECREF(module);
return -1;
}

if (PyCObject_Check(c_api_object))
PyIGraph_API = (void**)PyCObject_AsVoidPtr(c_api_object);

Py_DECREF(c_api_object);
Py_DECREF(module);
return 0;
PyIGraph_API = (void **)PyCapsule_Import("igraph._igraph._C_API", 0);
return (PyIGraph_API != NULL) ? 0 : -1;
}

#endif
Expand Down

0 comments on commit ecfced6

Please sign in to comment.