Skip to content

Commit

Permalink
Python 3.11 build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone committed Oct 30, 2022
1 parent 21e2dde commit 4d1158b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/modules/IcePy/Slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
// Python headers needed for PyEval_EvalCode.
//
#include <compile.h>
#include <eval.h>
// Use ceval.h instead of eval.h with Pyhthon 3.11 and greater
#if PY_VERSION_HEX > 0x030B0000
# include <ceval.h>
#else
# include <eval.h>
#endif

using namespace std;
using namespace IcePy;
Expand Down
5 changes: 5 additions & 0 deletions python/modules/IcePy/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,12 @@ IcePy::getFunction()
//
// Get name of current function.
//
// Use PyEval_GetFrame with Pyhthon >= 3.11
#if PY_VERSION_HEX > 0x030B0000
PyFrameObject *f = PyEval_GetFrame();
#else
PyFrameObject *f = PyThreadState_GET()->frame;
#endif
PyObjectHandle code = getAttr(reinterpret_cast<PyObject*>(f), "f_code", false);
assert(code.get());
PyObjectHandle func = getAttr(code.get(), "co_name", false);
Expand Down

0 comments on commit 4d1158b

Please sign in to comment.