1 |
eva 10/05/05 22:50:31 |
2 |
|
3 |
Added: rhythmbox-0.12-python-initialization.patch |
4 |
Removed: rhythmbox-0.12.5-fix-daap-plugin-linking.patch |
5 |
Log: |
6 |
Fix segfault with recent python, bug #318333. Clean up old revisions. |
7 |
(Portage version: 2.2_rc67/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 media-sound/rhythmbox/files/rhythmbox-0.12-python-initialization.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/rhythmbox/files/rhythmbox-0.12-python-initialization.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/rhythmbox/files/rhythmbox-0.12-python-initialization.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: rhythmbox-0.12-python-initialization.patch |
16 |
=================================================================== |
17 |
From 4394826f36fad0ad36ea773b6d4525dfcfcd389b Mon Sep 17 00:00:00 2001 |
18 |
From: Jonathan Matthew <jonathan@××××.org> |
19 |
Date: Wed, 05 May 2010 12:58:26 +0000 |
20 |
Subject: python: fix a number of python initialization problems (bug #617587) |
21 |
|
22 |
- pygtk.require("2.8") doesn't work - it's only after a major version, |
23 |
so we should pass in "2.0" instead |
24 |
- init_pygobject() is deprecated, use pygobject_init (and pass in the |
25 |
version we require) instead |
26 |
- init_pygtk() is a macro that returns from the current function on |
27 |
error, so we need to call it from a separate function for our error |
28 |
handling to work |
29 |
- if some aspect of python initialization failed, we were still using |
30 |
the pygobject GIL macros, which were crashing |
31 |
--- |
32 |
diff --git a/shell/main.c b/shell/main.c |
33 |
index 1f27fee..a4dd50a 100644 |
34 |
--- a/shell/main.c |
35 |
+++ b/shell/main.c |
36 |
@@ -35,6 +35,7 @@ |
37 |
#define NO_IMPORT_PYGOBJECT |
38 |
#define NO_IMPORT_PYGTK |
39 |
#include <pygobject.h> |
40 |
+#include "rb-python-module.h" |
41 |
|
42 |
/* make sure it's defined somehow */ |
43 |
#ifndef _XOPEN_SOURCE |
44 |
@@ -327,11 +328,15 @@ main (int argc, char **argv) |
45 |
|
46 |
rb_profile_start ("mainloop"); |
47 |
#ifdef ENABLE_PYTHON |
48 |
- pyg_begin_allow_threads; |
49 |
-#endif |
50 |
+ if (rb_python_init_successful ()) { |
51 |
+ pyg_begin_allow_threads; |
52 |
+ gtk_main (); |
53 |
+ pyg_end_allow_threads; |
54 |
+ } else { |
55 |
+ gtk_main (); |
56 |
+ } |
57 |
+#else |
58 |
gtk_main (); |
59 |
-#ifdef ENABLE_PYTHON |
60 |
- pyg_end_allow_threads; |
61 |
#endif |
62 |
rb_profile_end ("mainloop"); |
63 |
|
64 |
diff --git a/shell/rb-python-module.c b/shell/rb-python-module.c |
65 |
index 9e14731..1995a42 100644 |
66 |
--- a/shell/rb-python-module.c |
67 |
+++ b/shell/rb-python-module.c |
68 |
@@ -84,8 +84,16 @@ extern PyMethodDef pyrb_functions[]; |
69 |
/* We retreive this to check for correct class hierarchy */ |
70 |
static PyTypeObject *PyRBPlugin_Type; |
71 |
|
72 |
+static gboolean python_init_successful; |
73 |
+ |
74 |
G_DEFINE_TYPE (RBPythonModule, rb_python_module, G_TYPE_TYPE_MODULE); |
75 |
|
76 |
+static void |
77 |
+actually_init_pygtk (void) |
78 |
+{ |
79 |
+ init_pygtk (); |
80 |
+} |
81 |
+ |
82 |
void |
83 |
rb_python_module_init_python (void) |
84 |
{ |
85 |
@@ -98,6 +106,7 @@ rb_python_module_init_python (void) |
86 |
char *argv[] = { "rb", "rhythmdb", NULL }; |
87 |
GList *paths; |
88 |
|
89 |
+ python_init_successful = FALSE; |
90 |
if (Py_IsInitialized ()) { |
91 |
g_warning ("Python Should only be initialized once, since it's in class_init"); |
92 |
g_return_if_reached (); |
93 |
@@ -130,7 +139,7 @@ rb_python_module_init_python (void) |
94 |
|
95 |
PySys_SetArgv (1, argv); |
96 |
|
97 |
- /* pygtk.require("2.8") */ |
98 |
+ /* pygtk.require("2.0") */ |
99 |
pygtk = PyImport_ImportModule ("pygtk"); |
100 |
if (pygtk == NULL) { |
101 |
g_warning ("Could not import pygtk"); |
102 |
@@ -140,11 +149,15 @@ rb_python_module_init_python (void) |
103 |
|
104 |
mdict = PyModule_GetDict (pygtk); |
105 |
require = PyDict_GetItemString (mdict, "require"); |
106 |
- PyObject_CallObject (require, Py_BuildValue ("(S)", PyString_FromString ("2.8"))); |
107 |
+ PyObject_CallObject (require, Py_BuildValue ("(S)", PyString_FromString ("2.0"))); |
108 |
+ if (PyErr_Occurred ()) { |
109 |
+ g_warning ("pygtk.require(2.0) failed"); |
110 |
+ PyErr_Print(); |
111 |
+ return; |
112 |
+ } |
113 |
|
114 |
/* import gobject */ |
115 |
- init_pygobject (); |
116 |
- if (PyErr_Occurred ()) { |
117 |
+ if (pygobject_init (2, 16, 0) == NULL) { |
118 |
g_warning ("Could not initialize pygobject"); |
119 |
PyErr_Print(); |
120 |
return; |
121 |
@@ -154,7 +167,7 @@ rb_python_module_init_python (void) |
122 |
pyg_disable_warning_redirections (); |
123 |
|
124 |
/* import gtk */ |
125 |
- init_pygtk (); |
126 |
+ actually_init_pygtk (); |
127 |
if (PyErr_Occurred ()) { |
128 |
g_warning ("Could not initialize pygtk"); |
129 |
PyErr_Print(); |
130 |
@@ -172,7 +185,7 @@ rb_python_module_init_python (void) |
131 |
|
132 |
mdict = PyModule_GetDict (gtk); |
133 |
pygtk_version = PyDict_GetItemString (mdict, "pygtk_version"); |
134 |
- pygtk_required_version = Py_BuildValue ("(iii)", 2, 4, 0); |
135 |
+ pygtk_required_version = Py_BuildValue ("(iii)", 2, 8, 0); |
136 |
if (PyObject_Compare (pygtk_version, pygtk_required_version) == -1) { |
137 |
g_warning("PyGTK %s required, but %s found.", |
138 |
PyString_AsString (PyObject_Repr (pygtk_required_version)), |
139 |
@@ -264,6 +277,8 @@ rb_python_module_init_python (void) |
140 |
gettext_args = Py_BuildValue ("ss", GETTEXT_PACKAGE, GNOMELOCALEDIR); |
141 |
PyObject_CallObject (install, gettext_args); |
142 |
Py_DECREF (gettext_args); |
143 |
+ |
144 |
+ python_init_successful = TRUE; |
145 |
} |
146 |
|
147 |
static gboolean |
148 |
@@ -329,6 +344,11 @@ rb_python_module_load_with_gil (GTypeModule *module) |
149 |
PyGILState_STATE state; |
150 |
gboolean ret; |
151 |
|
152 |
+ if (python_init_successful == FALSE) { |
153 |
+ g_warning ("unable to load module as python runtime could not be initialized"); |
154 |
+ return FALSE; |
155 |
+ } |
156 |
+ |
157 |
state = pyg_gil_state_ensure (); |
158 |
ret = rb_python_module_load (module); |
159 |
pyg_gil_state_release (state); |
160 |
@@ -485,6 +505,12 @@ rb_python_module_new (const gchar *path, |
161 |
return result; |
162 |
} |
163 |
|
164 |
+gboolean |
165 |
+rb_python_init_successful (void) |
166 |
+{ |
167 |
+ return python_init_successful; |
168 |
+} |
169 |
+ |
170 |
/* --- these are not module methods, they are here out of convenience --- */ |
171 |
|
172 |
#if 0 |
173 |
diff --git a/shell/rb-python-module.h b/shell/rb-python-module.h |
174 |
index 5b2c152..30c1200 100644 |
175 |
--- a/shell/rb-python-module.h |
176 |
+++ b/shell/rb-python-module.h |
177 |
@@ -60,6 +60,8 @@ GObject *rb_python_module_new_object (RBPythonModule *module); |
178 |
|
179 |
void rb_python_module_init_python (void); |
180 |
|
181 |
+gboolean rb_python_init_successful (void); |
182 |
+ |
183 |
void rb_python_garbage_collect (void); |
184 |
|
185 |
void rb_python_shutdown (void); |
186 |
-- |
187 |
cgit v0.8.3.1 |