Skip to content

Commit a9e9e6f

Browse files
committed
Introduce make_caster_intrinsic<T>, to be able to undo the 2 changes from load_type to load_type<T>. 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
1 parent dda1b41 commit a9e9e6f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

include/pybind11/cast.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ class type_caster : public type_caster_for_class_<type> {};
4848
#ifdef PYBIND11_TYPE_CASTER_ODR_GUARD_ON
4949

5050
template <typename type>
51-
using make_caster = type_caster_odr_guard<intrinsic_t<type>, type_caster<intrinsic_t<type>>>;
51+
using make_caster_intrinsic = type_caster_odr_guard<type, type_caster<type>>;
5252

5353
#else
5454

5555
template <typename type>
56-
using make_caster = type_caster<intrinsic_t<type>>;
56+
using make_caster_intrinsic = type_caster<type>;
5757

5858
#endif
5959

60+
template <typename type>
61+
using make_caster = make_caster_intrinsic<intrinsic_t<type>>;
62+
6063
template <typename T>
6164
struct type_uses_smart_holder_type_caster {
6265
static constexpr bool value
@@ -1077,7 +1080,7 @@ struct return_value_policy_override<
10771080

10781081
// Basic python -> C++ casting; throws if casting fails
10791082
template <typename T>
1080-
make_caster<T> &load_type(make_caster<T> &conv, const handle &handle) {
1083+
make_caster_intrinsic<T> &load_type(make_caster_intrinsic<T> &conv, const handle &handle) {
10811084
static_assert(!detail::is_pyobject<T>::value,
10821085
"Internal error: type_caster should only be used for C++ types");
10831086
if (!conv.load(handle, true)) {
@@ -1097,7 +1100,7 @@ template <typename T>
10971100
make_caster<T> load_type(const handle &handle) {
10981101
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
10991102
make_caster<T> conv;
1100-
load_type<T>(conv, handle);
1103+
load_type(conv, handle);
11011104
return conv;
11021105
}
11031106

@@ -1235,7 +1238,7 @@ template <typename T>
12351238
enable_if_t<cast_is_temporary_value_reference<T>::value, T> cast_ref(object &&o,
12361239
make_caster<T> &caster) {
12371240
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
1238-
return cast_op<T>(load_type<T>(caster, o));
1241+
return cast_op<T>(load_type(caster, o));
12391242
}
12401243
template <typename T>
12411244
enable_if_t<!cast_is_temporary_value_reference<T>::value, T> cast_ref(object &&,

0 commit comments

Comments
 (0)