fix: make gil.h self-contained for PyPy/GraalPy and silence -Wredundant-decls gil.h evaluated PYBIND11_SIMPLE_GIL_MANAGEMENT before including common.h, which defines it on PyPy/GraalPy. Every existing TU included common.h first through pybind11.h, so this only surfaced when src/type_caster_base.cpp reached gil.h directly. Also suppress GCC -Wredundant-decls for the isinstance_generic declaration duplicated in pytypes.h. Assisted-by: ClaudeCode:claude-fable-5
diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index 4163673..0954759 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h
@@ -219,7 +219,11 @@ // (get_value_and_holder, allocate_layout, and deallocate_layout are declared inside // struct instance in detail/common.h; definitions are in type_caster_base-inl.h.) +PYBIND11_WARNING_PUSH +PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls") +// also forward-declared in pytypes.h bool isinstance_generic(handle obj, const std::type_info &tp); +PYBIND11_WARNING_POP handle get_object_handle(const void *ptr, const detail::type_info *type);
diff --git a/include/pybind11/gil.h b/include/pybind11/gil.h index 9e799b3..e43d4cb 100644 --- a/include/pybind11/gil.h +++ b/include/pybind11/gil.h
@@ -9,9 +9,12 @@ #pragma once +// common.h must come first: on PyPy/GraalPy it defines PYBIND11_SIMPLE_GIL_MANAGEMENT, +// which selects the branch below. +#include "detail/common.h" + #if defined(PYBIND11_SIMPLE_GIL_MANAGEMENT) -# include "detail/common.h" # include "gil_simple.h" PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) @@ -23,7 +26,6 @@ #else -# include "detail/common.h" # include "detail/internals.h" # include <cassert>