Skip to content

Commit

Permalink
Add support for Python 3.11 (See zeroc-ice/ice#1394)
Browse files Browse the repository at this point in the history
This patch is nearly identical to
zeroc-ice/ice@4d1158b with the
exception that I have just removed the compile.h and eval.h header
inclusions.  They have not been required since Python 2.4 as they
were moved into Python.h.
  • Loading branch information
chris-allan committed Oct 13, 2023
1 parent 6ff4f0e commit 73d8d5d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions 0002-python-311-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Only in zeroc-ice-3.6.5: setup.py.orig
diff --color -ur zeroc-ice-3.6.5.orig/src/Slice.cpp zeroc-ice-3.6.5/src/Slice.cpp
--- zeroc-ice-3.6.5.orig/src/Slice.cpp 2019-07-31 21:49:38.000000000 +0200
+++ zeroc-ice-3.6.5/src/Slice.cpp 2023-10-12 10:52:07.029069937 +0200
@@ -17,12 +17,6 @@
#include <Slice/Util.h>
#include <IceUtil/Options.h>

-//
-// Python headers needed for PyEval_EvalCode.
-//
-#include <compile.h>
-#include <eval.h>
-
using namespace std;
using namespace IcePy;
using namespace Slice;
diff --color -ur zeroc-ice-3.6.5.orig/src/Util.cpp zeroc-ice-3.6.5/src/Util.cpp
--- zeroc-ice-3.6.5.orig/src/Util.cpp 2019-07-31 21:49:38.000000000 +0200
+++ zeroc-ice-3.6.5/src/Util.cpp 2023-10-12 10:49:15.033366926 +0200
@@ -214,7 +214,12 @@
//
// 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 = PyObject_GetAttrString(reinterpret_cast<PyObject*>(f), STRCAST("f_code"));
assert(code.get());
PyObjectHandle func = PyObject_GetAttrString(code.get(), STRCAST("co_name"));

0 comments on commit 73d8d5d

Please sign in to comment.