From c34e750ba6089face466328e7c6b5d7927556dff Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 5 Aug 2026 20:19:38 -0400 Subject: [PATCH] fix: bump PYBIND11_INTERNALS_VERSION to 13 PR #5960 added noexcept to override_hash. With libstdc++, a noexcept hasher disables per-node hash caching in unordered containers, which changes the node layout of the override cache in internals. Modules built from master before and after #5960 both claim internals v12 but disagree on that layout. Bump to v13 so they cannot share internals. Also add a comment to prevent an accidental ABI change in the future. Closes #6090 Assisted-by: ClaudeCode:claude-fable-5 --- include/pybind11/detail/internals.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/pybind11/detail/internals.h b/include/pybind11/detail/internals.h index 7107b70688..8f85664f6c 100644 --- a/include/pybind11/detail/internals.h +++ b/include/pybind11/detail/internals.h @@ -39,11 +39,11 @@ /// further ABI-incompatible changes may be made before the ABI is officially /// changed to the new version. #ifndef PYBIND11_INTERNALS_VERSION -# define PYBIND11_INTERNALS_VERSION 12 +# define PYBIND11_INTERNALS_VERSION 13 #endif -#if PYBIND11_INTERNALS_VERSION < 12 -# error "PYBIND11_INTERNALS_VERSION 12 is the minimum for all platforms for pybind11 v3.1.0" +#if PYBIND11_INTERNALS_VERSION < 13 +# error "PYBIND11_INTERNALS_VERSION 13 is the minimum for all platforms for pybind11 v3.1.0" #endif PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) @@ -216,6 +216,9 @@ template using type_map = std::unordered_map; struct override_hash { + // With libstdc++, the hasher's noexcept determines whether unordered + // containers cache the hash in each node, changing the node layout, so + // adding/removing it requires a PYBIND11_INTERNALS_VERSION bump (#6090). size_t operator()(const std::pair &v) const noexcept { size_t value = std::hash()(v.first); value ^= std::hash()(v.second) + 0x9e3779b9 + (value << 6) + (value >> 2);