Skip to content

Commit 096472f

Browse files
vstinnerxrmx
authored andcommitted
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 ae7ecb0 commit 096472f

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
@@ -1166,7 +1166,9 @@ void uwsgi_python_init_apps() {
11661166

11671167
// prepare for stack suspend/resume
11681168
if (uwsgi.async > 1) {
1169-
#ifdef UWSGI_PY312
1169+
#ifdef UWSGI_PY314
1170+
up.current_py_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
1171+
#elif defined UWSGI_PY312
11701172
up.current_c_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
11711173
up.current_py_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
11721174
#elif defined UWSGI_PY311
@@ -1608,7 +1610,10 @@ void uwsgi_python_suspend(struct wsgi_request *wsgi_req) {
16081610
PyGILState_Release(pgst);
16091611

16101612
if (wsgi_req) {
1611-
#ifdef UWSGI_PY313
1613+
#ifdef UWSGI_PY314
1614+
up.current_py_recursion_remaining[wsgi_req->async_id] = tstate->py_recursion_remaining;
1615+
up.current_frame[wsgi_req->async_id] = tstate->current_frame;
1616+
#elif defined UWSGI_PY313
16121617
up.current_c_recursion_remaining[wsgi_req->async_id] = tstate->c_recursion_remaining;
16131618
up.current_py_recursion_remaining[wsgi_req->async_id] = tstate->py_recursion_remaining;
16141619
up.current_frame[wsgi_req->async_id] = tstate->current_frame;
@@ -1625,7 +1630,10 @@ void uwsgi_python_suspend(struct wsgi_request *wsgi_req) {
16251630
#endif
16261631
}
16271632
else {
1628-
#ifdef UWSGI_PY313
1633+
#ifdef UWSGI_PY314
1634+
up.current_main_py_recursion_remaining = tstate->py_recursion_remaining;
1635+
up.current_main_frame = tstate->current_frame;
1636+
#elif defined UWSGI_PY313
16291637
up.current_main_c_recursion_remaining = tstate->c_recursion_remaining;
16301638
up.current_main_py_recursion_remaining = tstate->py_recursion_remaining;
16311639
up.current_main_frame = tstate->current_frame;
@@ -1869,7 +1877,10 @@ void uwsgi_python_resume(struct wsgi_request *wsgi_req) {
18691877
PyGILState_Release(pgst);
18701878

18711879
if (wsgi_req) {
1872-
#ifdef UWSGI_PY313
1880+
#ifdef UWSGI_PY314
1881+
tstate->py_recursion_remaining = up.current_py_recursion_remaining[wsgi_req->async_id];
1882+
tstate->current_frame = up.current_frame[wsgi_req->async_id];
1883+
#elif defined UWSGI_PY313
18731884
tstate->c_recursion_remaining = up.current_c_recursion_remaining[wsgi_req->async_id];
18741885
tstate->py_recursion_remaining = up.current_py_recursion_remaining[wsgi_req->async_id];
18751886
tstate->current_frame = up.current_frame[wsgi_req->async_id];
@@ -1886,7 +1897,10 @@ void uwsgi_python_resume(struct wsgi_request *wsgi_req) {
18861897
#endif
18871898
}
18881899
else {
1889-
#ifdef UWSGI_PY313
1900+
#ifdef UWSGI_PY314
1901+
tstate->py_recursion_remaining = up.current_main_py_recursion_remaining;
1902+
tstate->current_frame = up.current_main_frame;
1903+
#elif defined UWSGI_PY313
18901904
tstate->c_recursion_remaining = up.current_main_c_recursion_remaining;
18911905
tstate->py_recursion_remaining = up.current_main_py_recursion_remaining;
18921906
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
@@ -172,7 +176,13 @@ struct uwsgi_python {
172176

173177
char *callable;
174178

175-
#ifdef UWSGI_PY313
179+
#ifdef UWSGI_PY314
180+
int *current_py_recursion_remaining;
181+
struct _PyInterpreterFrame **current_frame;
182+
183+
int current_main_py_recursion_remaining;
184+
struct _PyInterpreterFrame *current_main_frame;
185+
#elif defined UWSGI_PY313
176186
int *current_c_recursion_remaining;
177187
int *current_py_recursion_remaining;
178188
struct _PyInterpreterFrame **current_frame;

0 commit comments

Comments
 (0)