From 4e13032e81afd64c7ca3ec005169061be2ef8cbf Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 24 Jun 2022 21:50:50 -0700 Subject: [PATCH] Introduce `make_caster_intrinsic`, to be able to undo the 2 changes from `load_type` to `load_type`. This is to avoid breaking 2 `pybind11::detail::load_type()` calls found in the wild (Google global testing). One of the breakages in the wild was: https://github.com/google/tensorstore/blob/0f0f6007670a3588093acd9df77cce423e0de805/python/tensorstore/subscript_method.h#L61 --- include/pybind11/cast.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 139363c57..8cf42721a 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -48,15 +48,18 @@ class type_caster : public type_caster_for_class_ {}; #ifdef PYBIND11_TYPE_CASTER_ODR_GUARD_ON template -using make_caster = type_caster_odr_guard, type_caster>>; +using make_caster_intrinsic = type_caster_odr_guard>; #else template -using make_caster = type_caster>; +using make_caster_intrinsic = type_caster; #endif +template +using make_caster = make_caster_intrinsic>; + template struct type_uses_smart_holder_type_caster { static constexpr bool value @@ -1077,7 +1080,7 @@ struct return_value_policy_override< // Basic python -> C++ casting; throws if casting fails template -make_caster &load_type(make_caster &conv, const handle &handle) { +make_caster_intrinsic &load_type(make_caster_intrinsic &conv, const handle &handle) { static_assert(!detail::is_pyobject::value, "Internal error: type_caster should only be used for C++ types"); if (!conv.load(handle, true)) { @@ -1097,7 +1100,7 @@ template make_caster load_type(const handle &handle) { PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T) make_caster conv; - load_type(conv, handle); + load_type(conv, handle); return conv; } @@ -1235,7 +1238,7 @@ template enable_if_t::value, T> cast_ref(object &&o, make_caster &caster) { PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T) - return cast_op(load_type(caster, o)); + return cast_op(load_type(caster, o)); } template enable_if_t::value, T> cast_ref(object &&,