Skip to content

Commit 7d538a4

Browse files
authored
fix: make_static_property_type() (#4971)
Update make_static_property_type() to make it compatible with Python 3.13: set Py_TPFLAGS_MANAGED_DICT flag before calling PyType_Ready().
1 parent 6832289 commit 7d538a4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

include/pybind11/detail/class.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,16 @@ inline PyTypeObject *make_static_property_type() {
8686
type->tp_descr_get = pybind11_static_get;
8787
type->tp_descr_set = pybind11_static_set;
8888

89-
if (PyType_Ready(type) < 0) {
90-
pybind11_fail("make_static_property_type(): failure in PyType_Ready()!");
91-
}
92-
9389
# if PY_VERSION_HEX >= 0x030C0000
94-
// PRE 3.12 FEATURE FREEZE. PLEASE REVIEW AFTER FREEZE.
9590
// Since Python-3.12 property-derived types are required to
9691
// have dynamic attributes (to set `__doc__`)
9792
enable_dynamic_attributes(heap_type);
9893
# endif
9994

95+
if (PyType_Ready(type) < 0) {
96+
pybind11_fail("make_static_property_type(): failure in PyType_Ready()!");
97+
}
98+
10099
setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
101100
PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
102101

0 commit comments

Comments
 (0)