GNOME Bugzilla – Bug 620060
Don't assume we are initialized if python is
Last modified: 2010-06-27 19:24:41 UTC
+++ This bug was initially created as a clone of Bug #617600 +++ If python is initialized the python loaded assumes that it is, even if it is not the case. This causes issues when using gtkparasite which has its own python console that is initialized before libpeas has the chance.
Created attachment 162298 [details] [review] Don't assume the python plugin loader has been initialized if python has been Thanks for the reminder
Review of attachment 162298 [details] [review]: There is something that bugs me in this patch: you don't alter the cases where we check for Py_IsInitialized(), like in peas_python_shutdown(). But, since this last function will Finalize() the python interpreter, it is going to break things if you launch gtkparasite but can't init pygobject or gettext, because in this case peas_python_shutdown() will call Py_Finalize() and exit the interpreter... You can probably check against the status instead (or in addition) of Py_IsInitialized at the other places as well? ::: loaders/python/peas-plugin-loader-python.c @@ +39,3 @@ + PEAS_PYTHON_STATUS_FAILED, + PEAS_PYTHON_STATUS_SUCCESS +} PeasPythonStatusType; IMHO you should rename the statuses STATUS_NOT_RUN, etc, to make the code using this enum shorter (this would be similar to what's done for properties), or maybe INIT_NOT_RUN, INIT_FAILED, INIT_SUCCESS? @@ +393,1 @@ ends with success */ Please rewrap the comment text to avoid being wider than 80 chars @@ +414,3 @@ /* Python initialization */ + if (!Py_IsInitialized ()) + Py_Initialize (); Shouldn't you also protect PySys_SetArgv ?
Created attachment 164760 [details] [review] [Python] Don't assume libpeas's stuff is initialized if python is. We need to ensure we run our own initialization function even if python has already been initialized by someone else (either our host application or something like gtkparasite).
Created attachment 164761 [details] [review] [Python] Don't finalize python if we didn't initialize it. This is to avoid weird effects on other components that might be using python if we didn't initialize it ourselves.