Skip to content

Commit ecfced6

Browse files
authored
Merge pull request #763 from DavidRConnell/update-public-api
Update from deprecated PyCObject to PyCapsule
2 parents 055e836 + 1741af4 commit ecfced6

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

src/_igraph/igraphmodule_api.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,8 @@ extern "C" {
5656

5757
/* Return -1 and set exception on error, 0 on success */
5858
static int import_igraph(void) {
59-
PyObject *c_api_object;
60-
PyObject *module;
61-
62-
module = PyImport_ImportModule("igraph._igraph");
63-
if (module == 0)
64-
return -1;
65-
66-
c_api_object = PyObject_GetAttrString(module, "_C_API");
67-
if (c_api_object == 0) {
68-
Py_DECREF(module);
69-
return -1;
70-
}
71-
72-
if (PyCObject_Check(c_api_object))
73-
PyIGraph_API = (void**)PyCObject_AsVoidPtr(c_api_object);
74-
75-
Py_DECREF(c_api_object);
76-
Py_DECREF(module);
77-
return 0;
59+
PyIGraph_API = (void **)PyCapsule_Import("igraph._igraph._C_API", 0);
60+
return (PyIGraph_API != NULL) ? 0 : -1;
7861
}
7962

8063
#endif

0 commit comments

Comments
 (0)