Skip to content

Commit 8e1bfe2

Browse files
committed
fix(event-loop): fix _getLoopOnThread for Python 3.14 compatibility
1 parent 32369f4 commit 8e1bfe2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/PyEventLoop.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,14 @@ PyEventLoop PyEventLoop::_getLoopOnThread(PyThreadState *tstate) {
155155
// See https://github.com/python/cpython/blob/v3.13.0rc1/Include/internal/pycore_tstate.h#L17-L24
156156
using PyThreadStateHolder = struct { // _PyThreadStateImpl
157157
PyThreadState base;
158-
PyObject *asyncio_running_loop; // we only need the first field of `_PyThreadStateImpl`
158+
#if PY_VERSION_HEX >= 0x030e0000 // Python version is greater than 3.14
159+
// the struct is changed with more additional fields, see https://github.com/python/cpython/blob/v3.14.0rc3/Include/internal/pycore_tstate.h#L24-L40
160+
Py_ssize_t refcount;
161+
uintptr_t c_stack_top;
162+
uintptr_t c_stack_soft_limit;
163+
uintptr_t c_stack_hard_limit;
164+
#endif
165+
PyObject *asyncio_running_loop; // we only need the first few fields of `_PyThreadStateImpl`
159166
};
160167

161168
// Modified from https://github.com/python/cpython/blob/v3.13.0rc1/Modules/_asynciomodule.c#L3205-L3210

0 commit comments

Comments
 (0)