File tree Expand file tree Collapse file tree 1 file changed +2
-19
lines changed Expand file tree Collapse file tree 1 file changed +2
-19
lines changed Original file line number Diff line number Diff line change @@ -56,25 +56,8 @@ extern "C" {
56
56
57
57
/* Return -1 and set exception on error, 0 on success */
58
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
- 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 ;
78
61
}
79
62
80
63
#endif
You can’t perform that action at this time.
0 commit comments