summaryrefslogtreecommitdiff
path: root/extra/avogadro/fix-pycapsule.patch
blob: de4e2ca75b7da0bacda5d5ffc6eccde2286325ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
--- avogadro-1.0.1/libavogadro/src/python/sip.cpp	2010-05-02 17:31:22.000000000 +0100
+++ avogadro-1.0.1-pycapsule/libavogadro/src/python/sip.cpp	2010-11-23 19:00:09.000000000 +0000
@@ -62,12 +62,20 @@ bool init_sip_api()
     return false;
   }
   
+#ifdef SIP_USE_PYCAPSULE
+  if (!PyCapsule_IsValid(sip_capi_obj.ptr(), "sip._C_API")) {
+#else
   if (!PyCObject_Check(sip_capi_obj.ptr())) {
+#endif
     std::cout << "The _C_API object in the sip python module is invalid." << std::endl;
     return false;
   }
 
+#ifdef SIP_USE_PYCAPSULE
+  sip_API = reinterpret_cast<const sipAPIDef*>(PyCapsule_GetPointer(sip_capi_obj.ptr(), "sip._C_API"));
+#else
   sip_API = reinterpret_cast<const sipAPIDef*>(PyCObject_AsVoidPtr(sip_capi_obj.ptr()));
+#endif
 
   return true;
 }