diff options
author | Alessandro Decina <alessandro.d@gmail.com> | 2010-08-27 13:20:24 +0200 |
---|---|---|
committer | Alessandro Decina <alessandro.d@gmail.com> | 2010-08-27 13:20:24 +0200 |
commit | ca020b3dd7ae5e8f95bbcd2b6556f950a3586c60 (patch) | |
tree | 08524c3bae512b28d1881757b07f4f4f166ff3ea | |
parent | 84f6e267686cda13f99aa102e960f3042fb55f69 (diff) |
plugin: call pygtk.require("2.0") before importing pygobject. Fixes #623105.
Based on a patch from Leo Singer.
-rw-r--r-- | plugin/gstpythonplugin.c | 17 |
1 files changed, 16 insertions, 1 deletions
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; |