fix: fully deprecate get_type_of (deprecated in 2.6 but no warning (#5596)

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
Henry Schreiner
2025-04-08 23:43:49 -04:00
committed by GitHub
parent b70b8eb332
commit 73ad3099fb
3 changed files with 3 additions and 4 deletions

View File

@@ -2520,7 +2520,7 @@ detail::initimpl::pickle_factory<GetState, SetState> pickle(GetState &&g, SetSta
PYBIND11_NAMESPACE_BEGIN(detail)
inline str enum_name(handle arg) {
dict entries = arg.get_type().attr("__entries");
dict entries = type::handle_of(arg).attr("__entries");
for (auto kv : entries) {
if (handle(kv.second[int_(0)]).equal(arg)) {
return pybind11::str(kv.first);

View File

@@ -210,8 +210,7 @@ public:
#endif
}
// TODO PYBIND11_DEPRECATED(
// "Call py::type::handle_of(h) or py::type::of(h) instead of h.get_type()")
PYBIND11_DEPRECATED("Call py::type::handle_of(h) or py::type::of(h) instead of h.get_type()")
handle get_type() const;
private:

View File

@@ -219,7 +219,7 @@ TEST_SUBMODULE(class_, m) {
m.def("get_type_of", [](py::object ob) { return py::type::of(std::move(ob)); });
m.def("get_type_classic", [](py::handle h) { return h.get_type(); });
m.def("get_type_classic", [](py::handle h) { return py::type::handle_of(h); });
m.def("as_type", [](const py::object &ob) { return py::type(ob); });