--- /dev/null
+diff -Naur root/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx root_dev/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx
+--- root/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx 2020-08-17 14:41:56.000000000 +0200
++++ root_dev/bindings/pyroot/cppyy/CPyCppyy/src/CPPConstructor.cxx 2024-03-22 12:43:13.311091738 +0100
+@@ -11,6 +11,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*)
+@@ -123,7 +129,7 @@
+ 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);
+ }
+ }
+
+diff -Naur root/bindings/pyroot/cppyy/CPyCppyy/src/CPPInstance.cxx root_dev/bindings/pyroot/cppyy/CPyCppyy/src/CPPInstance.cxx
+--- root/bindings/pyroot/cppyy/CPyCppyy/src/CPPInstance.cxx 2020-08-17 14:41:56.000000000 +0200
++++ root_dev/bindings/pyroot/cppyy/CPyCppyy/src/CPPInstance.cxx 2024-03-22 13:35:13.353430656 +0100
+@@ -764,7 +764,6 @@
+ 0, // tp_as_buffer
+ Py_TPFLAGS_DEFAULT |
+ Py_TPFLAGS_BASETYPE |
+- Py_TPFLAGS_HAVE_GC |
+ Py_TPFLAGS_CHECKTYPES, // tp_flags
+ (char*)"cppyy object proxy (internal)", // tp_doc
+ 0, // tp_traverse
+diff -Naur root/bindings/pyroot/cppyy/CPyCppyy/src/CPPOverload.cxx root_dev/bindings/pyroot/cppyy/CPyCppyy/src/CPPOverload.cxx
+--- root/bindings/pyroot/cppyy/CPyCppyy/src/CPPOverload.cxx 2020-08-17 14:41:56.000000000 +0200
++++ root_dev/bindings/pyroot/cppyy/CPyCppyy/src/CPPOverload.cxx 2024-03-22 11:20:59.002747612 +0100
+@@ -1,7 +1,7 @@
+ // Bindings
+ #include "CPyCppyy.h"
+ #include "structmember.h" // from Python
+-#if PY_VERSION_HEX >= 0x02050000
++#if PY_VERSION_HEX >= 0x02050000 && PY_VERSION_HEX < 0x030B0000
+ #include "code.h" // from Python
+ #else
+ #include "compile.h" // from Python
+diff -Naur root/bindings/pyroot/cppyy/CPyCppyy/src/CustomPyTypes.cxx root_dev/bindings/pyroot/cppyy/CPyCppyy/src/CustomPyTypes.cxx
+--- root/bindings/pyroot/cppyy/CPyCppyy/src/CustomPyTypes.cxx 2020-08-17 14:41:56.000000000 +0200
++++ root_dev/bindings/pyroot/cppyy/CPyCppyy/src/CustomPyTypes.cxx 2024-03-22 13:36:53.326012656 +0100
+@@ -78,8 +78,7 @@
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ (ternaryfunc)tpc_call, // tp_call
+ 0, 0, 0, 0,
+- Py_TPFLAGS_DEFAULT |
+- Py_TPFLAGS_HAVE_GC, // tp_flags
++ Py_TPFLAGS_DEFAULT, // tp_flags
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ #if PY_VERSION_HEX >= 0x02030000
+ , 0 // tp_del
+diff -Naur root/bindings/pyroot/cppyy/CPyCppyy/src/MemoryRegulator.cxx root_dev/bindings/pyroot/cppyy/CPyCppyy/src/MemoryRegulator.cxx
+--- root/bindings/pyroot/cppyy/CPyCppyy/src/MemoryRegulator.cxx 2020-08-17 14:41:56.000000000 +0200
++++ root_dev/bindings/pyroot/cppyy/CPyCppyy/src/MemoryRegulator.cxx 2024-03-22 13:42:08.271843845 +0100
+@@ -45,7 +45,7 @@
+ ((PyVarObject&)CPyCppyy_NoneType).ob_size = 0;
+
+ CPyCppyy_NoneType.tp_name = const_cast<char*>("CPyCppyy_NoneType");
+- CPyCppyy_NoneType.tp_flags = Py_TPFLAGS_HAVE_RICHCOMPARE | Py_TPFLAGS_HAVE_GC;
++ CPyCppyy_NoneType.tp_flags = Py_TPFLAGS_HAVE_RICHCOMPARE;
+
+ CPyCppyy_NoneType.tp_traverse = (traverseproc)0;
+ CPyCppyy_NoneType.tp_clear = (inquiry)0;
+@@ -135,6 +135,7 @@
+ CPyCppyy_NoneType.tp_traverse = Py_TYPE(pyobj)->tp_traverse;
+ CPyCppyy_NoneType.tp_clear = Py_TYPE(pyobj)->tp_clear;
+ CPyCppyy_NoneType.tp_free = Py_TYPE(pyobj)->tp_free;
++ CPyCppyy_NoneType.tp_flags = Py_TYPE(pyobj)->tp_flags;
+ } else if (CPyCppyy_NoneType.tp_traverse != Py_TYPE(pyobj)->tp_traverse) {
+ // TODO: SystemError?
+ std::cerr << "in CPyCppyy::MemoryRegulater, unexpected object of type: "
+