Skip to content

Commit 56983ed

Browse files
committed
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
1 parent eadcf86 commit 56983ed

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

include/pybind11/detail/type_caster_base.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ struct values_and_holders {
219219
// (get_value_and_holder, allocate_layout, and deallocate_layout are declared inside
220220
// struct instance in detail/common.h; definitions are in type_caster_base-inl.h.)
221221

222+
PYBIND11_WARNING_PUSH
223+
PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls")
224+
// also forward-declared in pytypes.h
222225
bool isinstance_generic(handle obj, const std::type_info &tp);
226+
PYBIND11_WARNING_POP
223227

224228
handle get_object_handle(const void *ptr, const detail::type_info *type);
225229

include/pybind11/gil.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99

1010
#pragma once
1111

12+
// common.h must come first: on PyPy/GraalPy it defines PYBIND11_SIMPLE_GIL_MANAGEMENT,
13+
// which selects the branch below.
14+
#include "detail/common.h"
15+
1216
#if defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
1317

14-
# include "detail/common.h"
1518
# include "gil_simple.h"
1619

1720
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
@@ -23,7 +26,6 @@ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
2326

2427
#else
2528

26-
# include "detail/common.h"
2729
# include "detail/internals.h"
2830

2931
# include <cassert>

0 commit comments

Comments
 (0)