void-packages/srcpkgs/uwsgi/patches/01.python3.12.patch

37 lines
1.1 KiB
Diff

Python 3.12 hard-enforces that PyImport_AppendInittab not be invoked after
Py_Initialize, so move the module configuration to right before the interpreter
is initialized.
(The behavior prohibited in Python 3.12 was always "forbidden", but this was
not strictly enforced.)
--- a/plugins/python/python_plugin.c
+++ b/plugins/python/python_plugin.c
@@ -15,6 +15,8 @@
extern PyTypeObject uwsgi_InputType;
+PyObject *init_uwsgi3(void);
+
void uwsgi_opt_pythonpath(char *opt, char *value, void *foobar) {
int i;
@@ -261,6 +263,9 @@
wchar_t *pname = uwsgi_calloc(sizeof(wchar_t) * (strlen(program_name)+1));
mbstowcs(pname, program_name, strlen(program_name)+1);
Py_SetProgramName(pname);
+
+ // The module has to be configured before the interpreter is initialized
+ PyImport_AppendInittab("uwsgi", init_uwsgi3);
#else
Py_SetProgramName(program_name);
#endif
@@ -658,7 +663,6 @@
#ifdef PYTHREE
- PyImport_AppendInittab("uwsgi", init_uwsgi3);
new_uwsgi_module = PyImport_AddModule("uwsgi");
#else
new_uwsgi_module = Py_InitModule3("uwsgi", NULL, uwsgi_py_doc);