Gentoo Archives: gentoo-commits

From: Dirkjan Ochtman <djc@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: www-apache/mod_wsgi/, www-apache/mod_wsgi/files/
Date: Fri, 31 Dec 2021 15:49:31
Message-Id: 1640965761.e823909c5782c667e59d85e75d52e1802f1f8a90.djc@gentoo
1 commit: e823909c5782c667e59d85e75d52e1802f1f8a90
2 Author: t0b3 <thomas.bettler <AT> gmail <DOT> com>
3 AuthorDate: Thu Dec 16 18:24:44 2021 +0000
4 Commit: Dirkjan Ochtman <djc <AT> gentoo <DOT> org>
5 CommitDate: Fri Dec 31 15:49:21 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e823909c
7
8 www-apache/mod_wsgi: add python 3.10
9
10 Closes: https://bugs.gentoo.org/829359
11 Signed-off-by: Thomas Bettler <thomas.bettler <AT> gmail.com>
12 Signed-off-by: Dirkjan Ochtman <djc <AT> gentoo.org>
13
14 .../mod_wsgi/files/mod_wsgi-4.7.1-py310.patch | 126 +++++++++++++++++++++
15 www-apache/mod_wsgi/mod_wsgi-4.7.1-r1.ebuild | 6 +-
16 2 files changed, 131 insertions(+), 1 deletion(-)
17
18 diff --git a/www-apache/mod_wsgi/files/mod_wsgi-4.7.1-py310.patch b/www-apache/mod_wsgi/files/mod_wsgi-4.7.1-py310.patch
19 new file mode 100644
20 index 000000000000..274046d99ca0
21 --- /dev/null
22 +++ b/www-apache/mod_wsgi/files/mod_wsgi-4.7.1-py310.patch
23 @@ -0,0 +1,126 @@
24 +From b439f1c411a9479ccc03c16465cdff50fede79d3 Mon Sep 17 00:00:00 2001
25 +From: Petr Viktorin <encukou@×××××.com>
26 +Date: Thu, 10 Jun 2021 15:45:03 +0200
27 +Subject: [PATCH] Use Py_CompileString rather than
28 + PyParser_SimpleParseFile/PyNode_Compile
29 +From: https://github.com/GrahamDumpleton/mod_wsgi/commit/b439f1c411a9479ccc03c16465cdff50fede79d3
30 +
31 +---
32 + src/server/mod_wsgi.c | 68 +++++++++++++++++++++++++++++++---------
33 + src/server/wsgi_python.h | 1 -
34 + 2 files changed, 53 insertions(+), 16 deletions(-)
35 +
36 +diff --git a/src/server/mod_wsgi.c b/src/server/mod_wsgi.c
37 +index b657a748..4f1d8765 100644
38 +--- a/src/server/mod_wsgi.c
39 ++++ b/src/server/mod_wsgi.c
40 +@@ -3645,7 +3645,10 @@ static PyObject *wsgi_load_source(apr_pool_t *pool, request_rec *r,
41 + FILE *fp = NULL;
42 + PyObject *m = NULL;
43 + PyObject *co = NULL;
44 +- struct _node *n = NULL;
45 ++ char *source;
46 ++ size_t pos = 0;
47 ++ size_t allocated = 1024;
48 ++ size_t nread;
49 +
50 + #if defined(WIN32) && defined(APR_HAS_UNICODE_FS)
51 + apr_wchar_t wfilename[APR_PATH_MAX];
52 +@@ -3730,36 +3733,71 @@ static PyObject *wsgi_load_source(apr_pool_t *pool, request_rec *r,
53 + return NULL;
54 + }
55 +
56 +- n = PyParser_SimpleParseFile(fp, filename, Py_file_input);
57 +-
58 ++ source = malloc(allocated);
59 ++ if (source != NULL) {
60 ++ do {
61 ++ nread = fread(source + pos, 1, allocated - pos, fp);
62 ++ pos += nread;
63 ++ if (nread == 0) {
64 ++ if (ferror(fp)) {
65 ++ free(source);
66 ++ source = NULL;
67 ++ }
68 ++ break;
69 ++ }
70 ++ if (pos == allocated) {
71 ++ allocated *= 2;
72 ++ char *reallocated_source = realloc(source, allocated);
73 ++ if (reallocated_source == NULL) {
74 ++ free(source);
75 ++ source = NULL;
76 ++ break;
77 ++ }
78 ++ source = reallocated_source;
79 ++ }
80 ++ } while (!feof(fp));
81 ++ }
82 + fclose(fp);
83 +-
84 +- if (!n) {
85 ++ if (source == NULL) {
86 + Py_BEGIN_ALLOW_THREADS
87 + if (r) {
88 +- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
89 ++ ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
90 + "mod_wsgi (pid=%d, process='%s', application='%s'): "
91 +- "Failed to parse Python script file '%s'.", getpid(),
92 ++ "Could not read source file '%s'.", getpid(),
93 + process_group, application_group, filename);
94 + }
95 + else {
96 +- ap_log_error(APLOG_MARK, APLOG_ERR, 0, wsgi_server,
97 ++ ap_log_error(APLOG_MARK, APLOG_ERR, errno, wsgi_server,
98 + "mod_wsgi (pid=%d, process='%s', application='%s'): "
99 +- "Failed to parse Python script file '%s'.", getpid(),
100 ++ "Could not read source file '%s'.", getpid(),
101 + process_group, application_group, filename);
102 + }
103 + Py_END_ALLOW_THREADS
104 ++ return NULL;
105 ++ }
106 +
107 +- wsgi_log_python_error(r, NULL, filename, 0);
108 ++ co = Py_CompileString(filename, source, 0);
109 ++ free(source);
110 +
111 ++ if (!co) {
112 ++ Py_BEGIN_ALLOW_THREADS
113 ++ if (r) {
114 ++ ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
115 ++ "mod_wsgi (pid=%d, process='%s', application='%s'): "
116 ++ "Could not compile source file '%s'.", getpid(),
117 ++ process_group, application_group, filename);
118 ++ }
119 ++ else {
120 ++ ap_log_error(APLOG_MARK, APLOG_ERR, errno, wsgi_server,
121 ++ "mod_wsgi (pid=%d, process='%s', application='%s'): "
122 ++ "Could not compile source file '%s'.", getpid(),
123 ++ process_group, application_group, filename);
124 ++ }
125 ++ Py_END_ALLOW_THREADS
126 + return NULL;
127 + }
128 +
129 +- co = (PyObject *)PyNode_Compile(n, filename);
130 +- PyNode_Free(n);
131 +-
132 +- if (co)
133 +- m = PyImport_ExecCodeModuleEx((char *)name, co, (char *)filename);
134 ++ m = PyImport_ExecCodeModuleEx((char *)name, co, (char *)filename);
135 +
136 + Py_XDECREF(co);
137 +
138 +diff --git a/src/server/wsgi_python.h b/src/server/wsgi_python.h
139 +index fa06e2cb..3b34b731 100644
140 +--- a/src/server/wsgi_python.h
141 ++++ b/src/server/wsgi_python.h
142 +@@ -43,7 +43,6 @@
143 +
144 + #include "structmember.h"
145 + #include "compile.h"
146 +-#include "node.h"
147 + #include "osdefs.h"
148 + #include "frameobject.h"
149 +
150
151 diff --git a/www-apache/mod_wsgi/mod_wsgi-4.7.1-r1.ebuild b/www-apache/mod_wsgi/mod_wsgi-4.7.1-r1.ebuild
152 index e5ae886e528e..759f60c5f6d0 100644
153 --- a/www-apache/mod_wsgi/mod_wsgi-4.7.1-r1.ebuild
154 +++ b/www-apache/mod_wsgi/mod_wsgi-4.7.1-r1.ebuild
155 @@ -3,7 +3,7 @@
156
157 EAPI=6
158
159 -PYTHON_COMPAT=( python3_{6,7,8,9} )
160 +PYTHON_COMPAT=( python3_{8..10} )
161 PYTHON_REQ_USE="threads(+)"
162
163 inherit apache-module python-single-r1
164 @@ -27,6 +27,10 @@ APACHE2_MOD_FILE="${S}/src/server/.libs/${PN}.so"
165
166 DOCFILES="README.rst"
167
168 +PATCHES=(
169 + "${FILESDIR}/${P}-py310.patch"
170 +)
171 +
172 need_apache2
173
174 pkg_setup() {