From d0580760c378658446aadb62e701ea2c755f7d31 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 6 Mar 2026 17:52:54 -0500 Subject: [PATCH 1/2] chore: use PyType_GetFlags Signed-off-by: Henry Schreiner --- include/pybind11/attr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/attr.h b/include/pybind11/attr.h index b4486dc0f1..d337595a0b 100644 --- a/include/pybind11/attr.h +++ b/include/pybind11/attr.h @@ -378,7 +378,7 @@ struct type_record { #ifdef PYBIND11_BACKWARD_COMPATIBILITY_TP_DICTOFFSET dynamic_attr |= base_info->type->tp_dictoffset != 0; #else - dynamic_attr |= (base_info->type->tp_flags & Py_TPFLAGS_MANAGED_DICT) != 0; + dynamic_attr |= (PyType_GetFlags(base_info->type) & Py_TPFLAGS_MANAGED_DICT) != 0; #endif if (caster) { From 94a630a3589890e227173e3d4d7cba038882f7ce Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 6 Mar 2026 17:53:39 -0500 Subject: [PATCH 2/2] chore: use public VectorCall in 3.9+ Signed-off-by: Henry Schreiner --- include/pybind11/cast.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 1c4973b748..262cafc48d 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -2244,8 +2244,13 @@ class unpacking_collector { if (m_names) { nargs -= m_names.size(); } - PyObject *result = _PyObject_Vectorcall( - ptr, m_args.data() + 1, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, m_names.ptr()); + PyObject *result = +#if PY_VERSION_HEX >= 0x03090000 + PyObject_Vectorcall( +#else + _PyObject_Vectorcall( +#endif + ptr, m_args.data() + 1, nargs | PY_VECTORCALL_ARGUMENTS_OFFSET, m_names.ptr()); if (!result) { throw error_already_set(); }