summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2023-03-31 14:19:17 +0200
committerStefan Behnel <stefan_ml@behnel.de>2023-04-02 12:22:20 +0200
commitc96d7fd4f9589ccb308048c14a506684f911a3cc (patch)
tree2326c3a26614c5c1b0f25da5541994e212b1973e
parent74573879df24fc23202ddcebc6501cae6f881c18 (diff)
downloadcython-c96d7fd4f9589ccb308048c14a506684f911a3cc.tar.gz
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
-rw-r--r--Cython/Utility/Coroutine.c4
1 files changed, 4 insertions, 0 deletions
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