Skip to content

Commit 03f8786

Browse files
committed
plugins/python: Port to Python 3.14 beta 1
The PyThreadState.c_recursion_remaining member has been removed in Python 3.14 beta 1: python/cpython#133080
1 parent f57eed9 commit 03f8786

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

plugins/python/python_plugin.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,9 @@ void uwsgi_python_init_apps() {
12131213

12141214
// prepare for stack suspend/resume
12151215
if (uwsgi.async > 0) {
1216-
#ifdef UWSGI_PY312
1216+
#ifdef UWSGI_PY314
1217+
up.current_py_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
1218+
#elif defined UWSGI_PY312
12171219
up.current_c_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
12181220
up.current_py_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
12191221
#elif defined UWSGI_PY311
@@ -1659,7 +1661,10 @@ void uwsgi_python_suspend(struct wsgi_request *wsgi_req) {
16591661
PyGILState_Release(pgst);
16601662

16611663
if (wsgi_req) {
1662-
#ifdef UWSGI_PY313
1664+
#ifdef UWSGI_PY314
1665+
up.current_py_recursion_remaining[wsgi_req->async_id] = tstate->py_recursion_remaining;
1666+
up.current_frame[wsgi_req->async_id] = tstate->current_frame;
1667+
#elif defined UWSGI_PY313
16631668
up.current_c_recursion_remaining[wsgi_req->async_id] = tstate->c_recursion_remaining;
16641669
up.current_py_recursion_remaining[wsgi_req->async_id] = tstate->py_recursion_remaining;
16651670
up.current_frame[wsgi_req->async_id] = tstate->current_frame;
@@ -1676,7 +1681,10 @@ void uwsgi_python_suspend(struct wsgi_request *wsgi_req) {
16761681
#endif
16771682
}
16781683
else {
1679-
#ifdef UWSGI_PY313
1684+
#ifdef UWSGI_PY314
1685+
up.current_main_py_recursion_remaining = tstate->py_recursion_remaining;
1686+
up.current_main_frame = tstate->current_frame;
1687+
#elif defined UWSGI_PY313
16801688
up.current_main_c_recursion_remaining = tstate->c_recursion_remaining;
16811689
up.current_main_py_recursion_remaining = tstate->py_recursion_remaining;
16821690
up.current_main_frame = tstate->current_frame;
@@ -1920,7 +1928,10 @@ void uwsgi_python_resume(struct wsgi_request *wsgi_req) {
19201928
PyGILState_Release(pgst);
19211929

19221930
if (wsgi_req) {
1923-
#ifdef UWSGI_PY313
1931+
#ifdef UWSGI_PY314
1932+
tstate->py_recursion_remaining = up.current_py_recursion_remaining[wsgi_req->async_id];
1933+
tstate->current_frame = up.current_frame[wsgi_req->async_id];
1934+
#elif defined UWSGI_PY313
19241935
tstate->c_recursion_remaining = up.current_c_recursion_remaining[wsgi_req->async_id];
19251936
tstate->py_recursion_remaining = up.current_py_recursion_remaining[wsgi_req->async_id];
19261937
tstate->current_frame = up.current_frame[wsgi_req->async_id];
@@ -1937,7 +1948,10 @@ void uwsgi_python_resume(struct wsgi_request *wsgi_req) {
19371948
#endif
19381949
}
19391950
else {
1940-
#ifdef UWSGI_PY313
1951+
#ifdef UWSGI_PY314
1952+
tstate->py_recursion_remaining = up.current_main_py_recursion_remaining;
1953+
tstate->current_frame = up.current_main_frame;
1954+
#elif defined UWSGI_PY313
19411955
tstate->c_recursion_remaining = up.current_main_c_recursion_remaining;
19421956
tstate->py_recursion_remaining = up.current_main_py_recursion_remaining;
19431957
tstate->current_frame = up.current_main_frame;

plugins/python/uwsgi_python.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
# define UWSGI_PY313
3030
#endif
3131

32+
#if (PY_VERSION_HEX >= 0x030e0000)
33+
# define UWSGI_PY314
34+
#endif
35+
3236
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 7
3337
#define HAS_NOT_PyMemoryView_FromBuffer
3438
#endif
@@ -186,7 +190,13 @@ struct uwsgi_python {
186190

187191
char *callable;
188192

189-
#ifdef UWSGI_PY313
193+
#ifdef UWSGI_PY314
194+
int *current_py_recursion_remaining;
195+
struct _PyInterpreterFrame **current_frame;
196+
197+
int current_main_py_recursion_remaining;
198+
struct _PyInterpreterFrame *current_main_frame;
199+
#elif defined UWSGI_PY313
190200
int *current_c_recursion_remaining;
191201
int *current_py_recursion_remaining;
192202
struct _PyInterpreterFrame **current_frame;

0 commit comments

Comments
 (0)