Skip to content

Commit 3662688

Browse files
committed
Update to Python 3.14 beta 1
Beta 1 removed the PyThreadState.c_recursion_remaining member and the Py_C_RECURSION_LIMIT constant.
1 parent 9195828 commit 3662688

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/greenlet/TGreenlet.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ namespace greenlet
110110
_PyCFrame* cframe;
111111
int use_tracing;
112112
#endif
113-
#if GREENLET_PY312
113+
#if GREENLET_PY314
114+
int py_recursion_depth;
115+
#elif GREENLET_PY312
114116
int py_recursion_depth;
115117
int c_recursion_depth;
116118
#else

src/greenlet/TPythonState.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ PythonState::PythonState()
1212
,cframe(nullptr)
1313
,use_tracing(0)
1414
#endif
15-
#if GREENLET_PY312
15+
#if GREENLET_PY314
16+
,py_recursion_depth(0)
17+
#elif GREENLET_PY312
1618
,py_recursion_depth(0)
1719
,c_recursion_depth(0)
1820
#else
@@ -132,7 +134,9 @@ void PythonState::operator<<(const PyThreadState *const tstate) noexcept
132134
#endif
133135
#endif // GREENLET_USE_CFRAME
134136
#if GREENLET_PY311
135-
#if GREENLET_PY312
137+
#if GREENLET_PY314
138+
this->py_recursion_depth = tstate->py_recursion_limit - tstate->py_recursion_remaining;
139+
#elif GREENLET_PY312
136140
this->py_recursion_depth = tstate->py_recursion_limit - tstate->py_recursion_remaining;
137141
this->c_recursion_depth = Py_C_RECURSION_LIMIT - tstate->c_recursion_remaining;
138142
#else // not 312
@@ -207,7 +211,10 @@ void PythonState::operator>>(PyThreadState *const tstate) noexcept
207211
#endif
208212
#endif // GREENLET_USE_CFRAME
209213
#if GREENLET_PY311
210-
#if GREENLET_PY312
214+
#if GREENLET_PY314
215+
tstate->py_recursion_remaining = tstate->py_recursion_limit - this->py_recursion_depth;
216+
this->unexpose_frames();
217+
#elif GREENLET_PY312
211218
tstate->py_recursion_remaining = tstate->py_recursion_limit - this->py_recursion_depth;
212219
tstate->c_recursion_remaining = Py_C_RECURSION_LIMIT - this->c_recursion_depth;
213220
this->unexpose_frames();
@@ -253,7 +260,9 @@ inline void PythonState::will_switch_from(PyThreadState *const origin_tstate) no
253260
void PythonState::set_initial_state(const PyThreadState* const tstate) noexcept
254261
{
255262
this->_top_frame = nullptr;
256-
#if GREENLET_PY312
263+
#if GREENLET_PY314
264+
this->py_recursion_depth = tstate->py_recursion_limit - tstate->py_recursion_remaining;
265+
#elif GREENLET_PY312
257266
this->py_recursion_depth = tstate->py_recursion_limit - tstate->py_recursion_remaining;
258267
// XXX: TODO: Comment from a reviewer:
259268
// Should this be ``Py_C_RECURSION_LIMIT - tstate->c_recursion_remaining``?

0 commit comments

Comments
 (0)