From 952fc89eb214b3a06dc962d7fbfbc47f89bc4763 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 26 Feb 2022 18:09:06 -0500 Subject: [PATCH] FIX: import internal cpython headers to fix for py311 In 18b5dd68c6b616257ae243c0b6bb965ffc885a23 / https://github.com/python/cpython/pull/31530 / https://bugs.python.org/issue46836 The `_frame` struct was moved to an internal header, however the public API is primarily read-only, and cython needs to build _frame objects so still import the internal headers. --- Cython/Utility/Coroutine.c | 3 +++ Cython/Utility/Exceptions.c | 3 +++ Cython/Utility/ObjectHandling.c | 3 +++ Cython/Utility/Profile.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/Cython/Utility/Coroutine.c b/Cython/Utility/Coroutine.c index dc05a150eb8..b7ea282f358 100644 --- a/Cython/Utility/Coroutine.c +++ b/Cython/Utility/Coroutine.c @@ -499,6 +499,9 @@ static int __pyx_Generator_init(PyObject *module); /*proto*/ //@requires: ModuleSetupCode.c::IncludeStructmemberH #include +#if PY_VERSION_HEX >= 0x030b00a5 + #include "internal/pycore_frame.h" +#endif #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) diff --git a/Cython/Utility/Exceptions.c b/Cython/Utility/Exceptions.c index 326061fa3c5..ec633355a3d 100644 --- a/Cython/Utility/Exceptions.c +++ b/Cython/Utility/Exceptions.c @@ -784,6 +784,9 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, #include "compile.h" #include "frameobject.h" +#if PY_VERSION_HEX >= 0x030b00a5 + #include "internal/pycore_frame.h" +#endif #include "traceback.h" #if CYTHON_COMPILING_IN_LIMITED_API diff --git a/Cython/Utility/ObjectHandling.c b/Cython/Utility/ObjectHandling.c index 1ea8d6cef33..d7332e42815 100644 --- a/Cython/Utility/ObjectHandling.c +++ b/Cython/Utility/ObjectHandling.c @@ -2444,6 +2444,9 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, #if !CYTHON_VECTORCALL #if PY_VERSION_HEX >= 0x03080000 #include "frameobject.h" +#if PY_VERSION_HEX >= 0x030b00a5 + #include "internal/pycore_frame.h" +#endif #define __Pxy_PyFrame_Initialize_Offsets() #define __Pyx_PyFrame_GetLocalsplus(frame) ((frame)->f_localsplus) #else diff --git a/Cython/Utility/Profile.c b/Cython/Utility/Profile.c index 645ec953506..856c5871f74 100644 --- a/Cython/Utility/Profile.c +++ b/Cython/Utility/Profile.c @@ -37,6 +37,9 @@ #include "compile.h" #include "frameobject.h" +#if PY_VERSION_HEX >= 0x030b00a5 + #include "internal/pycore_frame.h" +#endif #include "traceback.h" #if CYTHON_PROFILE_REUSE_FRAME