File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ We have to save and restore this as well.
48
48
# define GREENLET_USE_CFRAME 0
49
49
#endif
50
50
51
+ #if PY_VERSION_HEX >= 0x30C0000
52
+ # define GREENLET_PY312 1
53
+ #else
54
+ # define GREENLET_PY312 0
55
+ #endif
56
+
51
57
#if PY_VERSION_HEX >= 0x30B00A4
52
58
/*
53
59
Greenlet won't compile on anything older than Python 3.11 alpha 4 (see
Original file line number Diff line number Diff line change @@ -826,7 +826,11 @@ void PythonState::operator<<(const PyThreadState *const tstate) G_NOEXCEPT
826
826
this ->use_tracing = tstate->cframe ->use_tracing ;
827
827
#endif
828
828
#if GREENLET_PY311
829
+ #if GREENLET_PY312
830
+ this ->recursion_depth = tstate->py_recursion_limit - tstate->py_recursion_remaining ;
831
+ #else
829
832
this ->recursion_depth = tstate->recursion_limit - tstate->recursion_remaining ;
833
+ #endif
830
834
this ->current_frame = tstate->cframe ->current_frame ;
831
835
this ->datastack_chunk = tstate->datastack_chunk ;
832
836
this ->datastack_top = tstate->datastack_top ;
@@ -862,7 +866,11 @@ void PythonState::operator>>(PyThreadState *const tstate) G_NOEXCEPT
862
866
tstate->cframe ->use_tracing = this ->use_tracing ;
863
867
#endif
864
868
#if GREENLET_PY311
869
+ #if GREENLET_PY312
870
+ tstate->py_recursion_remaining = tstate->py_recursion_limit - this ->recursion_depth ;
871
+ #else
865
872
tstate->recursion_remaining = tstate->recursion_limit - this ->recursion_depth ;
873
+ #endif
866
874
tstate->cframe ->current_frame = this ->current_frame ;
867
875
tstate->datastack_chunk = this ->datastack_chunk ;
868
876
tstate->datastack_top = this ->datastack_top ;
@@ -890,7 +898,9 @@ void PythonState::will_switch_from(PyThreadState *const origin_tstate) G_NOEXCEP
890
898
void PythonState::set_initial_state (const PyThreadState* const tstate) G_NOEXCEPT
891
899
{
892
900
this ->_top_frame = nullptr ;
893
- #if GREENLET_PY311
901
+ #if GREENLET_PY312
902
+ this ->recursion_depth = tstate->py_recursion_limit - tstate->py_recursion_remaining ;
903
+ #elif GREENLET_PY311
894
904
this ->recursion_depth = tstate->recursion_limit - tstate->recursion_remaining ;
895
905
#else
896
906
this ->recursion_depth = tstate->recursion_depth ;
You can’t perform that action at this time.
0 commit comments