!199 Fix Python 3.10 (PEP-620) incompatibility

From: @wangzengliang1 
Reviewed-by: @liuqinfei 
Signed-off-by: @liuqinfei
This commit is contained in:
openeuler-ci-bot 2023-07-22 08:56:47 +00:00 committed by Gitee
commit 82ca47f302
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 217 additions and 1 deletions

View File

@ -0,0 +1,140 @@
From a89999fee6f9bf55919b4cc34861922ccf1100e1 Mon Sep 17 00:00:00 2001
From: wangzengliang <wangzengliang2@huawei.com>
Date: Fri, 21 Jul 2023 16:00:41 +0800
Subject: [PATCH] Fix Python 3.10(PEP-620) incompatibility
copyed-by: https://github.com/boostorg/python/pull/328
From: Stefan Seefeld <stefan@seefeld.name>
---
src/boost/boost/python/detail/wrap_python.hpp | 5 +++++
src/boost/boost/python/object/make_instance.hpp | 2 +-
src/boost/libs/python/src/object/class.cpp | 15 +++++----------
src/boost/libs/python/src/object/enum.cpp | 2 +-
src/boost/libs/python/src/object/function.cpp | 2 +-
src/boost/libs/python/src/object/life_support.cpp | 2 +-
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/boost/boost/python/detail/wrap_python.hpp b/src/boost/boost/python/detail/wrap_python.hpp
index 13679dbb8..c3eba3ac6 100644
--- a/src/boost/boost/python/detail/wrap_python.hpp
+++ b/src/boost/boost/python/detail/wrap_python.hpp
@@ -230,6 +230,11 @@ typedef int pid_t;
#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_TYPE(obj) = (size)), (void)0)
+#endif
+
#ifdef __MWERKS__
# pragma warn_possunwant off
diff --git a/src/boost/boost/python/object/make_instance.hpp b/src/boost/boost/python/object/make_instance.hpp
index 31ec08f7c..5eb3aa9d9 100644
--- a/src/boost/boost/python/object/make_instance.hpp
+++ b/src/boost/boost/python/object/make_instance.hpp
@@ -47,7 +47,7 @@ struct make_instance_impl
// 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();
diff --git a/src/boost/libs/python/src/object/class.cpp b/src/boost/libs/python/src/object/class.cpp
index 9bb9683a3..2d1112298 100644
--- a/src/boost/libs/python/src/object/class.cpp
+++ b/src/boost/libs/python/src/object/class.cpp
@@ -208,7 +208,7 @@ namespace objects
{
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 @@ namespace objects
{
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 @@ namespace objects
// 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<int>(offsetof(instance<>,storage) + instance_size));
+ Py_SET_SIZE(result, -static_cast<int>(offsetof(instance<>,storage) + instance_size));
}
return (PyObject*)result;
}
@@ -470,7 +465,7 @@ namespace objects
{
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 @@ void* instance_holder::allocate(PyObject* self_, std::size_t holder_offset, std:
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
diff --git a/src/boost/libs/python/src/object/enum.cpp b/src/boost/libs/python/src/object/enum.cpp
index 10122ad1d..293e70589 100644
--- a/src/boost/libs/python/src/object/enum.cpp
+++ b/src/boost/libs/python/src/object/enum.cpp
@@ -153,7 +153,7 @@ namespace
{
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
diff --git a/src/boost/libs/python/src/object/function.cpp b/src/boost/libs/python/src/object/function.cpp
index 9d4745d10..787679e13 100644
--- a/src/boost/libs/python/src/object/function.cpp
+++ b/src/boost/libs/python/src/object/function.cpp
@@ -107,7 +107,7 @@ function::function(
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);
}
diff --git a/src/boost/libs/python/src/object/life_support.cpp b/src/boost/libs/python/src/object/life_support.cpp
index b7e9aa861..281c3bffc 100644
--- a/src/boost/libs/python/src/object/life_support.cpp
+++ b/src/boost/libs/python/src/object/life_support.cpp
@@ -93,7 +93,7 @@ PyObject* make_nurse_and_patient(PyObject* nurse, PyObject* patient)
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);
}
--
2.27.0

24
0019-include-memory.patch Normal file
View File

@ -0,0 +1,24 @@
From c76040b420284071ef9ea093c09c830379b31041 Mon Sep 17 00:00:00 2001
From: wangzengliang <wangzengliang2@huawei.com>
Date: Fri, 21 Jul 2023 17:27:24 +0800
Subject: [PATCH] include memory
---
src/include/buffer.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/include/buffer.h b/src/include/buffer.h
index 7c8f90e9f..71cb01935 100644
--- a/src/include/buffer.h
+++ b/src/include/buffer.h
@@ -41,6 +41,7 @@
#include <iosfwd>
#include <iomanip>
#include <list>
+#include <memory>
#include <vector>
#include <string>
#if __cplusplus >= 201703L
--
2.27.0

View File

@ -0,0 +1,46 @@
From 824b1101570d5a2417ef22e6a7fa358f4a0ffb9d Mon Sep 17 00:00:00 2001
From: wangzengliang <wangzengliang2@huawei.com>
Date: Fri, 21 Jul 2023 17:52:36 +0800
Subject: [PATCH] gcc12 need constexpr
---
src/common/dout.h | 4 ++--
src/libcephsqlite.cc | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/common/dout.h b/src/common/dout.h
index 421222d53..ae52c358b 100644
--- a/src/common/dout.h
+++ b/src/common/dout.h
@@ -99,11 +99,11 @@ namespace ceph::dout {
template<typename T>
struct dynamic_marker_t {
T value;
- operator T() const { return value; }
+ constexpr operator T() const { return value; }
};
template<typename T>
-dynamic_marker_t<T> need_dynamic(T&& t) {
+constexpr dynamic_marker_t<T> need_dynamic(T&& t) {
return dynamic_marker_t<T>{ std::forward<T>(t) };
}
diff --git a/src/libcephsqlite.cc b/src/libcephsqlite.cc
index 3db64a19f..a6e8a4883 100644
--- a/src/libcephsqlite.cc
+++ b/src/libcephsqlite.cc
@@ -380,8 +380,8 @@ static int FileSize(sqlite3_file *file, sqlite_int64 *osize)
static bool parsepath(std::string_view path, struct cephsqlite_fileloc* fileloc)
{
- static const std::regex re1{"^/*(\\*[[:digit:]]+):([[:alnum:]-_.]*)/([[:alnum:]-._]+)$"};
- static const std::regex re2{"^/*([[:alnum:]-_.]+):([[:alnum:]-_.]*)/([[:alnum:]-._]+)$"};
+ static const std::regex re1{"^/*(\\*[[:digit:]]+):([[:alnum:]\\-_.]*)/([[:alnum:]\\-._]+)$"};
+ static const std::regex re2{"^/*([[:alnum:]\\-_.]+):([[:alnum:]\\-_.]*)/([[:alnum:]\\-._]+)$"};
std::cmatch cm;
if (!std::regex_match(path.data(), cm, re1)) {
--
2.27.0

View File

@ -129,7 +129,7 @@
#################################################################################
Name: ceph
Version: 16.2.7
Release: 20
Release: 21
%if 0%{?fedora} || 0%{?rhel} || 0%{?openEuler}
Epoch: 2
%endif
@ -164,6 +164,9 @@ Patch14: 0014-fix-CVE-2022-3854.patch
Patch15: 0015-ceph-volume-add-judgment-for-ceph-volume-lvm-activat.patch
Patch16: 0016-fix-mgr-dashboard-frontend-build-depend.patch
Patch17: 0017-mgr-dashboard-support-multi-language.patch
Patch18: 0018-Fix-Python-3.10-PEP-620-incompatibility.patch
Patch19: 0019-include-memory.patch
Patch20: 0020-compiled-with-gcc12.patch
%if 0%{?suse_version}
# _insert_obs_source_lines_here
ExclusiveArch: x86_64 aarch64 ppc64le s390x
@ -2528,6 +2531,9 @@ exit 0
%config %{_sysconfdir}/prometheus/ceph/ceph_default_alerts.yml
%changelog
* Fri Jul 21 2023 wangzengliang <wangzengliang2@huawei.com> - 2:16.2.7-21
- Fix Python 3.10 <PEP 620> incompatibility
* Tue May 30 2023 zhuchao <chaotomzhu@gmail.com> - 2:16.2.7-20
- mgr dashboard support multi-language