Skip to content

Commit

Permalink
Merge pull request #2673 from Lalufu/Lalufu/chore-python313-reorg
Browse files Browse the repository at this point in the history
Minor rework of Python 3.13 support
  • Loading branch information
xrmx committed Sep 9, 2024
2 parents 7bdd6da + 420149c commit 3cdf109
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
32 changes: 16 additions & 16 deletions plugins/python/python_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1659,14 +1659,14 @@ void uwsgi_python_suspend(struct wsgi_request *wsgi_req) {
PyGILState_Release(pgst);

if (wsgi_req) {
#ifdef UWSGI_PY312
#ifdef UWSGI_PY313
up.current_c_recursion_remaining[wsgi_req->async_id] = tstate->c_recursion_remaining;
up.current_py_recursion_remaining[wsgi_req->async_id] = tstate->py_recursion_remaining;
#ifdef UWSGI_PY313
up.current_frame[wsgi_req->async_id] = tstate->current_frame;
#else
#elif defined UWSGI_PY312
up.current_c_recursion_remaining[wsgi_req->async_id] = tstate->c_recursion_remaining;
up.current_py_recursion_remaining[wsgi_req->async_id] = tstate->py_recursion_remaining;
up.current_frame[wsgi_req->async_id] = tstate->cframe;
#endif
#elif defined UWSGI_PY311
up.current_recursion_remaining[wsgi_req->async_id] = tstate->recursion_remaining;
up.current_frame[wsgi_req->async_id] = tstate->cframe;
Expand All @@ -1676,14 +1676,14 @@ void uwsgi_python_suspend(struct wsgi_request *wsgi_req) {
#endif
}
else {
#ifdef UWSGI_PY312
#ifdef UWSGI_PY313
up.current_main_c_recursion_remaining = tstate->c_recursion_remaining;
up.current_main_py_recursion_remaining = tstate->py_recursion_remaining;
#ifdef UWSGI_PY313
up.current_main_frame = tstate->current_frame;
#else
#elif defined UWSGI_PY312
up.current_main_c_recursion_remaining = tstate->c_recursion_remaining;
up.current_main_py_recursion_remaining = tstate->py_recursion_remaining;
up.current_main_frame = tstate->cframe;
#endif
#elif defined UWSGI_PY311
up.current_main_recursion_remaining = tstate->recursion_remaining;
up.current_main_frame = tstate->cframe;
Expand Down Expand Up @@ -1920,14 +1920,14 @@ void uwsgi_python_resume(struct wsgi_request *wsgi_req) {
PyGILState_Release(pgst);

if (wsgi_req) {
#ifdef UWSGI_PY312
#ifdef UWSGI_PY313
tstate->c_recursion_remaining = up.current_c_recursion_remaining[wsgi_req->async_id];
tstate->py_recursion_remaining = up.current_py_recursion_remaining[wsgi_req->async_id];
#ifdef UWSGI_PY313
tstate->current_frame = up.current_frame[wsgi_req->async_id];
#else
#elif defined UWSGI_PY312
tstate->c_recursion_remaining = up.current_c_recursion_remaining[wsgi_req->async_id];
tstate->py_recursion_remaining = up.current_py_recursion_remaining[wsgi_req->async_id];
tstate->cframe = up.current_frame[wsgi_req->async_id];
#endif
#elif defined UWSGI_PY311
tstate->recursion_remaining = up.current_recursion_remaining[wsgi_req->async_id];
tstate->cframe = up.current_frame[wsgi_req->async_id];
Expand All @@ -1937,14 +1937,14 @@ void uwsgi_python_resume(struct wsgi_request *wsgi_req) {
#endif
}
else {
#ifdef UWSGI_PY312
#ifdef UWSGI_PY313
tstate->c_recursion_remaining = up.current_main_c_recursion_remaining;
tstate->py_recursion_remaining = up.current_main_py_recursion_remaining;
#ifdef UWSGI_PY313
tstate->current_frame = up.current_main_frame;
#else
#elif defined UWSGI_PY312
tstate->c_recursion_remaining = up.current_main_c_recursion_remaining;
tstate->py_recursion_remaining = up.current_main_py_recursion_remaining;
tstate->cframe = up.current_main_frame;
#endif
#elif defined UWSGI_PY311
tstate->recursion_remaining = up.current_main_recursion_remaining;
tstate->cframe = up.current_main_frame;
Expand Down
16 changes: 8 additions & 8 deletions plugins/python/uwsgi_python.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,22 @@ struct uwsgi_python {

char *callable;

#ifdef UWSGI_PY312
#ifdef UWSGI_PY313
int *current_c_recursion_remaining;
int *current_py_recursion_remaining;
#ifdef UWSGI_PY313
struct _PyInterpreterFrame **current_frame;
#else
_PyCFrame **current_frame;
#endif

int current_main_c_recursion_remaining;
int current_main_py_recursion_remaining;
#ifdef UWSGI_PY313
struct _PyInterpreterFrame *current_main_frame;
#else
#elif defined UWSGI_PY312
int *current_c_recursion_remaining;
int *current_py_recursion_remaining;
_PyCFrame **current_frame;

int current_main_c_recursion_remaining;
int current_main_py_recursion_remaining;
_PyCFrame *current_main_frame;
#endif
#elif defined UWSGI_PY311
int *current_recursion_remaining;
_PyCFrame **current_frame;
Expand Down

0 comments on commit 3cdf109

Please sign in to comment.