chore: some minor CPython API cleanup (#6005)

* chore: use PyType_GetFlags

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>

* chore: use public VectorCall in 3.9+

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>

---------

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
This commit is contained in:
Henry Schreiner
2026-03-22 17:27:20 -04:00
committed by GitHub
parent 4d51aefc2c
commit 1c72409f7f
2 changed files with 8 additions and 3 deletions

View File

@@ -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) {

View File

@@ -2240,8 +2240,13 @@ public:
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();
}