From 98878b3953906fb3a234f86c17889f3ecdea80d8 Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Dec 13 2023 15:57:54 +0000 Subject: Fix make_static_property_type() on Python 3.13 - Fixes: rhbz#2252083 --- diff --git a/4971.patch b/4971.patch new file mode 100644 index 0000000..af414a9 --- /dev/null +++ b/4971.patch @@ -0,0 +1,37 @@ +From 2e42734d61f68407d6a74a3a37d24222085f0f28 Mon Sep 17 00:00:00 2001 +From: Victor Stinner +Date: Wed, 13 Dec 2023 16:16:04 +0100 +Subject: [PATCH] fix: make_static_property_type() + +Update make_static_property_type() to make it compatible with Python +3.13: set Py_TPFLAGS_MANAGED_DICT flag before calling PyType_Ready(). +--- + include/pybind11/detail/class.h | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/include/pybind11/detail/class.h b/include/pybind11/detail/class.h +index b317271674..60fed8dc65 100644 +--- a/include/pybind11/detail/class.h ++++ b/include/pybind11/detail/class.h +@@ -86,17 +86,16 @@ inline PyTypeObject *make_static_property_type() { + type->tp_descr_get = pybind11_static_get; + type->tp_descr_set = pybind11_static_set; + +- if (PyType_Ready(type) < 0) { +- pybind11_fail("make_static_property_type(): failure in PyType_Ready()!"); +- } +- + # if PY_VERSION_HEX >= 0x030C0000 +- // PRE 3.12 FEATURE FREEZE. PLEASE REVIEW AFTER FREEZE. + // Since Python-3.12 property-derived types are required to + // have dynamic attributes (to set `__doc__`) + enable_dynamic_attributes(heap_type); + # endif + ++ if (PyType_Ready(type) < 0) { ++ pybind11_fail("make_static_property_type(): failure in PyType_Ready()!"); ++ } ++ + setattr((PyObject *) type, "__module__", str("pybind11_builtins")); + PYBIND11_SET_OLDPY_QUALNAME(type, name_obj); + diff --git a/pybind11.spec b/pybind11.spec index e4e3fcf..85176e5 100644 --- a/pybind11.spec +++ b/pybind11.spec @@ -17,7 +17,7 @@ Name: pybind11 Version: 2.11.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Seamless operability between C++11 and Python License: BSD URL: https://github.com/pybind/pybind11 @@ -28,6 +28,8 @@ Patch1: pybind11-2.10.1-hpath.patch # Adapt to changed function name in Python 3.13 Patch2: https://github.com/pybind/pybind11/pull/4902.patch +# Fix make_static_property_type() on Python 3.13 +Patch3: https://github.com/pybind/pybind11/pull/4971.patch BuildRequires: make %if %{python2_enabled} @@ -112,6 +114,7 @@ This package contains the Python 3 files. %setup -q %patch1 -p1 -b .hpath %patch2 -p1 -b .4902 +%patch3 -p1 -b .4971 %build pys="" @@ -185,6 +188,10 @@ PYBIND11_USE_CMAKE=true %py3_install "--install-purelib" "%{python3_sitearch}" %endif %changelog +* Wed Dec 13 2023 Miro Hrončok - 2.11.1-2 +- Fix make_static_property_type() on Python 3.13 +- Fixes: rhbz#2252083 + * Mon Jul 24 2023 Susi Lehtola - 2.11.1-1 - Update to 2.11.1.