We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 055e836 + 1741af4 commit ecfced6Copy full SHA for ecfced6
1 file changed
src/_igraph/igraphmodule_api.h
@@ -56,25 +56,8 @@ extern "C" {
56
57
/* Return -1 and set exception on error, 0 on success */
58
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
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
77
- return 0;
+ PyIGraph_API = (void **)PyCapsule_Import("igraph._igraph._C_API", 0);
+ return (PyIGraph_API != NULL) ? 0 : -1;
78
}
79
80
#endif
0 commit comments