diff --git a/include/swigbind11/swigbind11.hpp b/include/swigbind11/swigbind11.hpp index fe5b1f8..e72175e 100644 --- a/include/swigbind11/swigbind11.hpp +++ b/include/swigbind11/swigbind11.hpp @@ -28,7 +28,7 @@ inline auto split_python_type_name(std::string_view type_name) -> std::tuple() + " instead of " + py::str(python_type).cast()}; } @@ -110,7 +110,7 @@ auto py_swig_cast(std::shared_ptr src, std::string_view python_type_name) -> /* NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) */ obj.attr("_swigbind11_shared_ptr") = reinterpret_cast(swigbind11_shared_ptr); /* monkeypatch the SWIG type with a custom deleter */ - py::handle swig_type = obj.get_type(); + py::handle swig_type = py::type::of(obj); if (!py::hasattr(swig_type, "__del__")) { swig_type.attr("__del__") = py::cpp_function( [](py::object self /* NOLINT(performance-unnecessary-value-param) */) {