From 5ff1242a9b4424daa0f65ad9539647131bca7723 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 3 May 2023 08:17:18 +0200 Subject: [PATCH] backport compat fix for python 3.10+ PEP 620 cherry-picked from Debian boost 1.74 package [0], adapted to the bundled 1.75 boost included by ceph. Note that 1.75 has the fopen compat patch already included. [0]: https://salsa.debian.org/debian/boost/-/commit/107cd01182da102a78e0356776621d6a01b6906d Signed-off-by: Thomas Lamprecht --- patches/0017-python3.10-pep-620.patch | 116 ++++++++++++++++++++++++++ patches/series | 1 + 2 files changed, 117 insertions(+) create mode 100644 patches/0017-python3.10-pep-620.patch diff --git a/patches/0017-python3.10-pep-620.patch b/patches/0017-python3.10-pep-620.patch new file mode 100644 index 000000000..bfb2eabae --- /dev/null +++ b/patches/0017-python3.10-pep-620.patch @@ -0,0 +1,116 @@ +Description: Fix Python 3.10 (PEP-620) incompatibility +Origin: upstream, https://github.com/boostorg/python/commit/500194edb7833d0627ce7a2595fec49d0aae2484 +Author: Stefan Seefeld +Last-Update: 2020-11-13 + +--- a/src/boost/boost/python/detail/wrap_python.hpp ++++ b/src/boost/boost/python/detail/wrap_python.hpp +@@ -227,7 +227,11 @@ + + # define PyVarObject_HEAD_INIT(type, size) \ + PyObject_HEAD_INIT(type) size, ++#endif + ++#if PY_VERSION_HEX < 0x030900A4 ++# define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0) ++# define Py_SET_SIZE(obj, size) ((Py_SIZE(obj) = (size)), (void)0) + #endif + + +--- a/src/boost/boost/python/object/make_instance.hpp ++++ b/src/boost/boost/python/object/make_instance.hpp +@@ -47,7 +47,7 @@ + + // Note the position of the internally-stored Holder, + // for the sake of destruction +- Py_SIZE(instance) = offsetof(instance_t, storage); ++ Py_SET_SIZE(instance, offsetof(instance_t, storage)); + + // Release ownership of the python object + protect.cancel(); +--- a/src/boost/libs/python/src/object/class.cpp ++++ b/src/boost/libs/python/src/object/class.cpp +@@ -208,7 +208,7 @@ + { + if (static_data_object.tp_dict == 0) + { +- Py_TYPE(&static_data_object) = &PyType_Type; ++ Py_SET_TYPE(&static_data_object, &PyType_Type); + static_data_object.tp_base = &PyProperty_Type; + if (PyType_Ready(&static_data_object)) + return 0; +@@ -316,7 +316,7 @@ + { + if (class_metatype_object.tp_dict == 0) + { +- Py_TYPE(&class_metatype_object) = &PyType_Type; ++ Py_SET_TYPE(&class_metatype_object, &PyType_Type); + class_metatype_object.tp_base = &PyType_Type; + if (PyType_Ready(&class_metatype_object)) + return type_handle(); +@@ -374,12 +374,7 @@ + // like, so we'll store the total size of the object + // there. A negative number indicates that the extra + // instance memory is not yet allocated to any holders. +-#if PY_VERSION_HEX >= 0x02060000 +- Py_SIZE(result) = +-#else +- result->ob_size = +-#endif +- -(static_cast(offsetof(instance<>,storage) + instance_size)); ++ Py_SET_SIZE(result,-static_cast(offsetof(instance<>,storage) + instance_size)); + } + return (PyObject*)result; + } +@@ -470,7 +465,7 @@ + { + if (class_type_object.tp_dict == 0) + { +- Py_TYPE(&class_type_object) = incref(class_metatype().get()); ++ Py_SET_TYPE(&class_type_object, incref(class_metatype().get())); + class_type_object.tp_base = &PyBaseObject_Type; + if (PyType_Ready(&class_type_object)) + return type_handle(); +@@ -739,7 +734,7 @@ + assert(holder_offset >= offsetof(objects::instance<>,storage)); + + // Record the fact that the storage is occupied, noting where it starts +- Py_SIZE(self) = holder_offset; ++ Py_SET_SIZE(self, holder_offset); + return (char*)self + holder_offset; + } + else +--- a/src/boost/libs/python/src/object/enum.cpp ++++ b/src/boost/libs/python/src/object/enum.cpp +@@ -153,7 +153,7 @@ + { + if (enum_type_object.tp_dict == 0) + { +- Py_TYPE(&enum_type_object) = incref(&PyType_Type); ++ Py_SET_TYPE(&enum_type_object, incref(&PyType_Type)); + #if PY_VERSION_HEX >= 0x03000000 + enum_type_object.tp_base = &PyLong_Type; + #else +--- a/src/boost/libs/python/src/object/function.cpp ++++ b/src/boost/libs/python/src/object/function.cpp +@@ -107,7 +107,7 @@ + PyObject* p = this; + if (Py_TYPE(&function_type) == 0) + { +- Py_TYPE(&function_type) = &PyType_Type; ++ Py_SET_TYPE(&function_type, &PyType_Type); + ::PyType_Ready(&function_type); + } + +--- a/src/boost/libs/python/src/object/life_support.cpp ++++ b/src/boost/libs/python/src/object/life_support.cpp +@@ -93,7 +93,7 @@ + + if (Py_TYPE(&life_support_type) == 0) + { +- Py_TYPE(&life_support_type) = &PyType_Type; ++ Py_SET_TYPE(&life_support_type, &PyType_Type); + PyType_Ready(&life_support_type); + } + + diff --git a/patches/series b/patches/series index 82b6a8587..a224d0f04 100644 --- a/patches/series +++ b/patches/series @@ -10,3 +10,4 @@ 0014-fix-service-ordering-avoid-Before-remote-fs-pre.targ.patch 0015-d-control-drop-outdated-build-dependencies-and-bump-.patch 0016-d-rules-fix-no-restart-on-upgrade.patch +0017-python3.10-pep-620.patch -- 2.39.2