Python plugin: Also check for _PyGtk_API being a PyCapsule
authorHolger Berndt <hb@claws-mail.org>
Sun, 26 Jan 2014 12:14:21 +0000 (13:14 +0100)
committerHolger Berndt <hb@claws-mail.org>
Mon, 27 Jan 2014 21:31:11 +0000 (22:31 +0100)
Seems like Arch Linux patched pygtk to wrap into a PyCapsule instead
of a PyCObject.

Thanks to Drew Ferguson for reporting.

src/plugins/python/python-hooks.c

index fd7ba60..4cd1cb5 100644 (file)
@@ -196,9 +196,15 @@ parasite_python_init(char **error)
          */
         if (cobject != NULL)
         {
-            if (PyCObject_Check(cobject))
+            if (PyCObject_Check(cobject)) {
                 _PyGtk_API = (struct _PyGtk_FunctionStruct*)
                 PyCObject_AsVoidPtr(cobject);
+            }
+#if PY_VERSION_HEX >= 0x02070000
+            else if (PyCapsule_IsValid(cobject, "gtk._gtk._PyGtk_API")) {
+                _PyGtk_API = (struct _PyGtk_FunctionStruct*)PyCapsule_GetPointer(cobject, "gtk._gtk._PyGtk_API");
+            }
+#endif
             else {
               *error = g_strdup("Parasite: Could not find _PyGtk_API object");
                 return 0;