From c96d7fd4f9589ccb308048c14a506684f911a3cc Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 31 Mar 2023 14:19:17 +0200 Subject: Avoid accessing "PyGenObject->gi_code", which was removed in CPython 3.12a6 and replaced with a C-API function. See https://github.com/python/cpython/pull/100749 --- Cython/Utility/Coroutine.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cython/Utility/Coroutine.c b/Cython/Utility/Coroutine.c index 1ad27df26..a02578acd 100644 --- a/Cython/Utility/Coroutine.c +++ b/Cython/Utility/Coroutine.c @@ -185,7 +185,11 @@ static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) { } else #endif #if CYTHON_COMPILING_IN_CPYTHON && defined(CO_ITERABLE_COROUTINE) +#if PY_VERSION_HEX >= 0x030C00A6 + if (PyGen_CheckExact(obj) && (PyGen_GetCode(obj)->co_flags & CO_ITERABLE_COROUTINE)) { +#else if (PyGen_CheckExact(obj) && ((PyGenObject*)obj)->gi_code && ((PyCodeObject *)((PyGenObject*)obj)->gi_code)->co_flags & CO_ITERABLE_COROUTINE) { +#endif // Python generator marked with "@types.coroutine" decorator return __Pyx_NewRef(obj); } else -- cgit v1.2.1