Hi,
The build of v6.26/00 with Python 3.10.2 failed in compiling CPPConstructor.cxx as the following:
In file included from /usr/include/python3.11/Python.h:42,
from /home/furutaka/work/root/root.git/bindings/pyroot/cppyy/CPyCppyy/src/CPyCppyy.h:35,
from /home/furutaka/work/root/root.git/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx:2:
/home/furutaka/work/root/root.git/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx: In member function ‘virtual PyObject* CPyCppyy::CPPConstructor::Call(CPyCppyy::CPPInstance*&, PyObject*, PyObject*, CPyCppyy::CallContext*)’:
/home/furutaka/work/root/root.git/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx:125:17: error: lvalue required as left operand of assignment
125 | Py_TYPE(self) = (PyTypeObject*)pyclass;
| ^~~~~~~
The following change seems to fix this, according to this report:
diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx b/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx
index 0c564aff83..395fb27bdb 100644
--- a/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx
+++ b/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx
@@ -12,6 +12,12 @@
// Standard
#include <string>
+// https://bugzilla.redhat.com/show_bug.cgi?id=2021796
+#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
+static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type)
+{ ob->ob_type = type; }
+#define Py_SET_TYPE(ob, type) _Py_SET_TYPE((PyObject*)(ob), type)
+#endif
//- protected members --------------------------------------------------------
bool CPyCppyy::CPPConstructor::InitExecutor_(Executor*& executor, CallContext*)
@@ -122,7 +128,7 @@ PyObject* CPyCppyy::CPPConstructor::Call(
if (pyclass) {
self->SetSmart((PyObject*)Py_TYPE(self));
Py_DECREF((PyObject*)Py_TYPE(self));
- Py_TYPE(self) = (PyTypeObject*)pyclass;
+ Py_SET_TYPE(self,(PyTypeObject*)pyclass);
}
}
Please read tips for efficient and successful posting and posting code
ROOT Version: v6.26/00
Platform: Fedora 35 (x86_64)
Compiler: c++ (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)