Skip to content

Commit d5c014f

Browse files
committed
Avoid accessing "PyGenObject->gi_code", which was removed in CPython 3.12a6 and replaced with a C-API function.
See python/cpython#100749
1 parent 1177bd6 commit d5c014f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Cython/Utility/Coroutine.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) {
178178
} else
179179
#endif
180180
#if CYTHON_COMPILING_IN_CPYTHON && defined(CO_ITERABLE_COROUTINE)
181+
#if PY_VERSION_HEX >= 0x030C00A6
182+
if (PyGen_CheckExact(obj) && (PyGen_GetCode(obj)->co_flags & CO_ITERABLE_COROUTINE)) {
183+
#else
181184
if (PyGen_CheckExact(obj) && ((PyGenObject*)obj)->gi_code && ((PyCodeObject *)((PyGenObject*)obj)->gi_code)->co_flags & CO_ITERABLE_COROUTINE) {
185+
#endif
182186
// Python generator marked with "@types.coroutine" decorator
183187
return __Pyx_NewRef(obj);
184188
} else

0 commit comments

Comments
 (0)