1 |
commit: 43fd8ae135f9d301246b5450ddf521138158e91a |
2 |
Author: Thomas Bettler <thomas.bettler <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue Dec 14 19:51:20 2021 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 20 12:35:31 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=43fd8ae1 |
7 |
|
8 |
www-servers/uwsgi: fix python 3.10 (upstream patches) |
9 |
|
10 |
[sam: revbump to propagate fixes.] |
11 |
|
12 |
Closes: https://bugs.gentoo.org/829204 |
13 |
Closes: https://github.com/gentoo/gentoo/pull/23301 |
14 |
Signed-off-by: Thomas Bettler <thomas.bettler <AT> gmail.com> |
15 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
16 |
|
17 |
.../uwsgi/files/uwsgi-2.0.19.1-py310-fix.patch | 36 ++++++ |
18 |
.../files/uwsgi-2.0.19.1-pynode-compile.patch | 123 +++++++++++++++++++++ |
19 |
...19.1-r107.ebuild => uwsgi-2.0.19.1-r108.ebuild} | 5 + |
20 |
3 files changed, 164 insertions(+) |
21 |
|
22 |
diff --git a/www-servers/uwsgi/files/uwsgi-2.0.19.1-py310-fix.patch b/www-servers/uwsgi/files/uwsgi-2.0.19.1-py310-fix.patch |
23 |
new file mode 100644 |
24 |
index 000000000000..8fe64d1b3d3b |
25 |
--- /dev/null |
26 |
+++ b/www-servers/uwsgi/files/uwsgi-2.0.19.1-py310-fix.patch |
27 |
@@ -0,0 +1,36 @@ |
28 |
+https://github.com/unbit/uwsgi/commit/c8c4bd1b5439217f2cb2f146caf162de69638bc1 |
29 |
+ |
30 |
+From c8c4bd1b5439217f2cb2f146caf162de69638bc1 Mon Sep 17 00:00:00 2001 |
31 |
+From: Cyrille Pontvieux <cyrille@×××××××.net> |
32 |
+Date: Thu, 1 Jul 2021 12:45:29 +0200 |
33 |
+Subject: [PATCH] Allow to compile on Python versions with more that two digits |
34 |
+ (Python 3.10) |
35 |
+ |
36 |
+--- |
37 |
+ plugins/python/pyloader.c | 6 +++--- |
38 |
+ 1 file changed, 3 insertions(+), 3 deletions(-) |
39 |
+ |
40 |
+diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c |
41 |
+index d8ab6fe35..3a1465d67 100644 |
42 |
+--- a/plugins/python/pyloader.c |
43 |
++++ b/plugins/python/pyloader.c |
44 |
+@@ -22,7 +22,7 @@ PyMethodDef uwsgi_eventfd_write_method[] = { {"uwsgi_eventfd_write", py_eventfd_ |
45 |
+ void set_dyn_pyhome(char *home, uint16_t pyhome_len) { |
46 |
+ |
47 |
+ |
48 |
+- char venv_version[15]; |
49 |
++ char venv_version[30]; |
50 |
+ PyObject *site_module; |
51 |
+ |
52 |
+ PyObject *pysys_dict = get_uwsgi_pydict("sys"); |
53 |
+@@ -45,8 +45,8 @@ void set_dyn_pyhome(char *home, uint16_t pyhome_len) { |
54 |
+ PyDict_SetItemString(pysys_dict, "prefix", venv_path); |
55 |
+ PyDict_SetItemString(pysys_dict, "exec_prefix", venv_path); |
56 |
+ |
57 |
+- venv_version[14] = 0; |
58 |
+- if (snprintf(venv_version, 15, "/lib/python%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION) == -1) { |
59 |
++ bzero(venv_version, 30); |
60 |
++ if (snprintf(venv_version, 30, "/lib/python%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION) == -1) { |
61 |
+ return; |
62 |
+ } |
63 |
+ |
64 |
|
65 |
diff --git a/www-servers/uwsgi/files/uwsgi-2.0.19.1-pynode-compile.patch b/www-servers/uwsgi/files/uwsgi-2.0.19.1-pynode-compile.patch |
66 |
new file mode 100644 |
67 |
index 000000000000..6bcf04ae2bc3 |
68 |
--- /dev/null |
69 |
+++ b/www-servers/uwsgi/files/uwsgi-2.0.19.1-pynode-compile.patch |
70 |
@@ -0,0 +1,123 @@ |
71 |
+https://github.com/unbit/uwsgi/commit/8c890c84604a0477b46a66eab8a620733f596cc8 |
72 |
+ |
73 |
+From 8c890c84604a0477b46a66eab8a620733f596cc8 Mon Sep 17 00:00:00 2001 |
74 |
+From: Riccardo Magliocchetti <riccardo.magliocchetti@×××××.com> |
75 |
+Date: Sun, 22 Nov 2020 18:20:19 +0100 |
76 |
+Subject: [PATCH] plugins/python: use Py_CompileString |
77 |
+ |
78 |
+Instead of the deprecated PyParser_SimpleParseString, PyParser_SimpleParseFile |
79 |
+and PyNode_Compile. |
80 |
+While at it fixup a possible null pointer dereference when uwsgi_open_and_read |
81 |
+returns an empty string. |
82 |
+ |
83 |
+See https://bugs.python.org/issue40939 |
84 |
+--- |
85 |
+ plugins/python/pyloader.c | 12 +----------- |
86 |
+ plugins/python/python_plugin.c | 36 ++++++++++++++-------------------- |
87 |
+ 2 files changed, 16 insertions(+), 32 deletions(-) |
88 |
+ |
89 |
+diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c |
90 |
+index a63c375b5..d8ab6fe35 100644 |
91 |
+--- a/plugins/python/pyloader.c |
92 |
++++ b/plugins/python/pyloader.c |
93 |
+@@ -757,25 +757,15 @@ PyObject *uwsgi_eval_loader(void *arg1) { |
94 |
+ |
95 |
+ PyObject *wsgi_eval_module, *wsgi_eval_callable = NULL; |
96 |
+ |
97 |
+- struct _node *wsgi_eval_node = NULL; |
98 |
+ PyObject *wsgi_compiled_node; |
99 |
+ |
100 |
+- wsgi_eval_node = PyParser_SimpleParseString(code, Py_file_input); |
101 |
+- if (!wsgi_eval_node) { |
102 |
+- PyErr_Print(); |
103 |
+- uwsgi_log( "failed to parse <eval> code\n"); |
104 |
+- exit(UWSGI_FAILED_APP_CODE); |
105 |
+- } |
106 |
+- |
107 |
+- wsgi_compiled_node = (PyObject *) PyNode_Compile(wsgi_eval_node, "uwsgi_eval_config"); |
108 |
+- |
109 |
++ wsgi_compiled_node = Py_CompileString(code, "uwsgi_eval_config", Py_file_input); |
110 |
+ if (!wsgi_compiled_node) { |
111 |
+ PyErr_Print(); |
112 |
+ uwsgi_log( "failed to compile eval code\n"); |
113 |
+ exit(UWSGI_FAILED_APP_CODE); |
114 |
+ } |
115 |
+ |
116 |
+- |
117 |
+ wsgi_eval_module = PyImport_ExecCodeModule("uwsgi_eval_config", wsgi_compiled_node); |
118 |
+ if (!wsgi_eval_module) { |
119 |
+ PyErr_Print(); |
120 |
+diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c |
121 |
+index 37d0b7bbf..79f29d43c 100644 |
122 |
+--- a/plugins/python/python_plugin.c |
123 |
++++ b/plugins/python/python_plugin.c |
124 |
+@@ -473,8 +473,7 @@ UWSGI_RELEASE_GIL |
125 |
+ |
126 |
+ PyObject *uwsgi_pyimport_by_filename(char *name, char *filename) { |
127 |
+ |
128 |
+- FILE *pyfile; |
129 |
+- struct _node *py_file_node = NULL; |
130 |
++ char *pycontent; |
131 |
+ PyObject *py_compiled_node, *py_file_module; |
132 |
+ int is_a_package = 0; |
133 |
+ struct stat pystat; |
134 |
+@@ -483,7 +482,7 @@ PyObject *uwsgi_pyimport_by_filename(char *name, char *filename) { |
135 |
+ |
136 |
+ if (!uwsgi_check_scheme(filename)) { |
137 |
+ |
138 |
+- pyfile = fopen(filename, "r"); |
139 |
++ FILE *pyfile = fopen(filename, "r"); |
140 |
+ if (!pyfile) { |
141 |
+ uwsgi_log("failed to open python file %s\n", filename); |
142 |
+ return NULL; |
143 |
+@@ -507,37 +506,32 @@ PyObject *uwsgi_pyimport_by_filename(char *name, char *filename) { |
144 |
+ } |
145 |
+ } |
146 |
+ |
147 |
+- py_file_node = PyParser_SimpleParseFile(pyfile, real_filename, Py_file_input); |
148 |
+- if (!py_file_node) { |
149 |
+- PyErr_Print(); |
150 |
+- uwsgi_log("failed to parse file %s\n", real_filename); |
151 |
+- if (is_a_package) |
152 |
++ fclose(pyfile); |
153 |
++ pycontent = uwsgi_simple_file_read(real_filename); |
154 |
++ |
155 |
++ if (!pycontent) { |
156 |
++ if (is_a_package) { |
157 |
+ free(real_filename); |
158 |
+- fclose(pyfile); |
159 |
++ } |
160 |
++ uwsgi_log("no data read from file %s\n", real_filename); |
161 |
+ return NULL; |
162 |
+ } |
163 |
+ |
164 |
+- fclose(pyfile); |
165 |
+ } |
166 |
+ else { |
167 |
+ size_t pycontent_size = 0; |
168 |
+- char *pycontent = uwsgi_open_and_read(filename, &pycontent_size, 1, NULL); |
169 |
++ pycontent = uwsgi_open_and_read(filename, &pycontent_size, 1, NULL); |
170 |
+ |
171 |
+- if (pycontent) { |
172 |
+- py_file_node = PyParser_SimpleParseString(pycontent, Py_file_input); |
173 |
+- if (!py_file_node) { |
174 |
+- PyErr_Print(); |
175 |
+- uwsgi_log("failed to parse url %s\n", real_filename); |
176 |
+- return NULL; |
177 |
+- } |
178 |
++ if (!pycontent) { |
179 |
++ uwsgi_log("no data read from url %s\n", real_filename); |
180 |
++ return NULL; |
181 |
+ } |
182 |
+ } |
183 |
+ |
184 |
+- py_compiled_node = (PyObject *) PyNode_Compile(py_file_node, real_filename); |
185 |
+- |
186 |
++ py_compiled_node = Py_CompileString(pycontent, real_filename, Py_file_input); |
187 |
+ if (!py_compiled_node) { |
188 |
+ PyErr_Print(); |
189 |
+- uwsgi_log("failed to compile python file %s\n", real_filename); |
190 |
++ uwsgi_log("failed to compile %s\n", real_filename); |
191 |
+ return NULL; |
192 |
+ } |
193 |
+ |
194 |
|
195 |
diff --git a/www-servers/uwsgi/uwsgi-2.0.19.1-r107.ebuild b/www-servers/uwsgi/uwsgi-2.0.19.1-r108.ebuild |
196 |
similarity index 99% |
197 |
rename from www-servers/uwsgi/uwsgi-2.0.19.1-r107.ebuild |
198 |
rename to www-servers/uwsgi/uwsgi-2.0.19.1-r108.ebuild |
199 |
index c418baa38343..c547c3316a71 100644 |
200 |
--- a/www-servers/uwsgi/uwsgi-2.0.19.1-r107.ebuild |
201 |
+++ b/www-servers/uwsgi/uwsgi-2.0.19.1-r108.ebuild |
202 |
@@ -128,6 +128,11 @@ RDEPEND="${CDEPEND} |
203 |
uwsgi_plugins_rrdtool? ( net-analyzer/rrdtool )" |
204 |
BDEPEND="virtual/pkgconfig" |
205 |
|
206 |
+PATCHES=( |
207 |
+ "${FILESDIR}/${P}-py310-fix.patch" |
208 |
+ "${FILESDIR}/${P}-pynode-compile.patch" |
209 |
+) |
210 |
+ |
211 |
S="${WORKDIR}/${MY_P}" |
212 |
|
213 |
src_unpack() { |