From ca020b3dd7ae5e8f95bbcd2b6556f950a3586c60 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Fri, 27 Aug 2010 13:20:24 +0200 Subject: plugin: call pygtk.require("2.0") before importing pygobject. Fixes #623105. Based on a patch from Leo Singer. --- plugin/gstpythonplugin.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugin/gstpythonplugin.c b/plugin/gstpythonplugin.c index a483d35..70199d9 100644 --- a/plugin/gstpythonplugin.c +++ b/plugin/gstpythonplugin.c @@ -43,6 +43,20 @@ np_init_pygobject (void) PyObject *gobject = NULL; PyObject *main_module = NULL; PyObject *mdict = NULL; + PyObject *pygtk = NULL; + + pygtk = PyImport_ImportModule ("pygtk"); + if (pygtk == NULL) { + PyErr_Print (); + GST_WARNING ("could not import pygtk"); + goto beach; + } + + if (!(PyObject_CallMethod (pygtk, "require", "s", "2.0"))) { + GST_WARNING ("could not run pygtk.require"); + PyErr_Print (); + goto beach; + } gobject = PyImport_ImportModule ("gobject"); if (gobject == NULL) { @@ -54,7 +68,7 @@ np_init_pygobject (void) main_module = PyImport_AddModule ("__main__"); mdict = PyModule_GetDict (gobject); - PyObject *cobject = PyDict_GetItemString (mdict, "_PyGObject_API"); + PyObject *cobject = PyMapping_GetItemString (mdict, "_PyGObject_API"); if (cobject == NULL) { GST_WARNING ("could not find _PyGObject_API"); goto beach; @@ -77,6 +91,7 @@ np_init_pygobject (void) res = TRUE; beach: + Py_XDECREF (pygtk); Py_XDECREF (gobject); return res; -- cgit v1.2.3