@@ -636,7 +636,7 @@ class type_caster_generic {
636
636
// / native typeinfo, or when the native one wasn't able to produce a value.
637
637
PYBIND11_NOINLINE bool try_load_foreign_module_local (handle src) {
638
638
constexpr auto *local_key = PYBIND11_MODULE_LOCAL_ID;
639
- const auto pytype = src. get_type ( );
639
+ const auto pytype = type::handle_of (src );
640
640
if (!hasattr (pytype, local_key))
641
641
return false ;
642
642
@@ -1130,7 +1130,7 @@ template <> class type_caster<void> : public type_caster<void_type> {
1130
1130
}
1131
1131
1132
1132
/* Check if this is a C++ type */
1133
- auto &bases = all_type_info ((PyTypeObject *) h. get_type ( ).ptr ());
1133
+ auto &bases = all_type_info ((PyTypeObject *) type::handle_of (h ).ptr ());
1134
1134
if (bases.size () == 1 ) { // Only allowing loading from a single-value type
1135
1135
value = values_and_holders (reinterpret_cast <instance *>(h.ptr ())).begin ()->value_ptr ();
1136
1136
return true ;
@@ -1708,7 +1708,7 @@ template <typename T, typename SFINAE> type_caster<T, SFINAE> &load_type(type_ca
1708
1708
throw cast_error (" Unable to cast Python instance to C++ type (compile in debug mode for details)" );
1709
1709
#else
1710
1710
throw cast_error (" Unable to cast Python instance of type " +
1711
- (std::string) str (handle. get_type ( )) + " to C++ type '" + type_id<T>() + " '" );
1711
+ (std::string) str (type::handle_of (handle )) + " to C++ type '" + type_id<T>() + " '" );
1712
1712
#endif
1713
1713
}
1714
1714
return conv;
@@ -1759,7 +1759,7 @@ detail::enable_if_t<!detail::move_never<T>::value, T> move(object &&obj) {
1759
1759
throw cast_error (" Unable to cast Python instance to C++ rvalue: instance has multiple references"
1760
1760
" (compile in debug mode for details)" );
1761
1761
#else
1762
- throw cast_error (" Unable to move from Python " + (std::string) str (obj. get_type ( )) +
1762
+ throw cast_error (" Unable to move from Python " + (std::string) str (type::handle_of (obj )) +
1763
1763
" instance to C++ " + type_id<T>() + " instance: instance has multiple references" );
1764
1764
#endif
1765
1765
@@ -2206,13 +2206,13 @@ PYBIND11_NAMESPACE_END(detail)
2206
2206
2207
2207
2208
2208
template<typename T>
2209
- type type::of () {
2209
+ handle type::handle_of () {
2210
2210
static_assert (
2211
2211
std::is_base_of<detail::type_caster_generic, detail::make_caster<T>>::value,
2212
2212
" py::type::of<T> only supports the case where T is a registered C++ types."
2213
2213
);
2214
2214
2215
- return type ((PyObject*) detail::get_type_handle (typeid (T), true ). ptr (), borrowed_t () );
2215
+ return detail::get_type_handle (typeid (T), true );
2216
2216
}
2217
2217
2218
2218
0 commit comments