75 lines
2.7 KiB
Diff
75 lines
2.7 KiB
Diff
From 6d2e3a9e8d5ca1e735301824fd2a7136db9eeb81 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= <thrnciar@redhat.com>
|
|
Date: Fri, 17 Mar 2023 11:59:10 +0100
|
|
Subject: [PATCH] Rename recursion limits to add compatibility with Python 3.12
|
|
|
|
---
|
|
src/greenlet/greenlet.c | 19 ++++++++++++++++---
|
|
src/greenlet/greenlet.h | 6 ++++++
|
|
2 files changed, 22 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/greenlet/greenlet.c b/src/greenlet/greenlet.c
|
|
index 2f3ad6e..6165064 100644
|
|
--- a/src/greenlet/greenlet.c
|
|
+++ b/src/greenlet/greenlet.c
|
|
@@ -527,7 +527,10 @@ g_switchstack(void)
|
|
{ /* save state */
|
|
PyGreenlet* current = ts_current;
|
|
PyThreadState* tstate = PyThreadState_GET();
|
|
-#if GREENLET_PY311
|
|
+#if GREENLET_PY312
|
|
+ current->recursion_depth = (tstate->py_recursion_limit
|
|
+ - tstate->py_recursion_remaining);
|
|
+#elif GREENLET_PY311
|
|
current->recursion_depth = (tstate->recursion_limit
|
|
- tstate->recursion_remaining);
|
|
#else
|
|
@@ -620,7 +623,14 @@ g_switchstack(void)
|
|
*/
|
|
tstate->cframe->use_tracing = ts__g_switchstack_use_tracing;
|
|
#endif
|
|
-#if GREENLET_PY311
|
|
+#if GREENLET_PY312
|
|
+ tstate->py_recursion_remaining = (tstate->py_recursion_limit
|
|
+ - target->recursion_depth);
|
|
+ tstate->cframe->current_frame = target->current_frame;
|
|
+ tstate->datastack_chunk = target->datastack_chunk;
|
|
+ tstate->datastack_top = target->datastack_top;
|
|
+ tstate->datastack_limit = target->datastack_limit;
|
|
+#elif GREENLET_PY311
|
|
tstate->recursion_remaining = (tstate->recursion_limit
|
|
- target->recursion_depth);
|
|
tstate->cframe->current_frame = target->current_frame;
|
|
@@ -899,7 +909,10 @@ static int GREENLET_NOINLINE(g_initialstub)(void* mark)
|
|
}
|
|
self->top_frame = NULL;
|
|
green_clear_exc(self);
|
|
-#if GREENLET_PY311
|
|
+#if GREENLET_PY312
|
|
+ self->recursion_depth = (PyThreadState_GET()->py_recursion_limit
|
|
+ - PyThreadState_GET()->py_recursion_remaining);
|
|
+#elif GREENLET_PY311
|
|
self->recursion_depth = (PyThreadState_GET()->recursion_limit
|
|
- PyThreadState_GET()->recursion_remaining);
|
|
#else
|
|
diff --git a/src/greenlet/greenlet.h b/src/greenlet/greenlet.h
|
|
index c788b2f..e20c580 100644
|
|
--- a/src/greenlet/greenlet.h
|
|
+++ b/src/greenlet/greenlet.h
|
|
@@ -23,6 +23,12 @@ extern "C" {
|
|
# define _PyCFrame CFrame
|
|
#endif
|
|
|
|
+#if PY_VERSION_HEX >= 0x30C00A6
|
|
+# define GREENLET_PY312 1
|
|
+#else
|
|
+# define GREENLET_PY312 0
|
|
+#endif
|
|
+
|
|
typedef struct _greenlet {
|
|
PyObject_HEAD
|
|
char* stack_start;
|
|
--
|
|
2.38.1
|
|
|