Skip to content

Commit 73ad309

Browse files
authored
fix: fully deprecate get_type_of (deprecated in 2.6 but no warning (#5596)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent b70b8eb commit 73ad309

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

include/pybind11/pybind11.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2520,7 +2520,7 @@ detail::initimpl::pickle_factory<GetState, SetState> pickle(GetState &&g, SetSta
25202520
PYBIND11_NAMESPACE_BEGIN(detail)
25212521

25222522
inline str enum_name(handle arg) {
2523-
dict entries = arg.get_type().attr("__entries");
2523+
dict entries = type::handle_of(arg).attr("__entries");
25242524
for (auto kv : entries) {
25252525
if (handle(kv.second[int_(0)]).equal(arg)) {
25262526
return pybind11::str(kv.first);

include/pybind11/pytypes.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ class object_api : public pyobject_tag {
210210
#endif
211211
}
212212

213-
// TODO PYBIND11_DEPRECATED(
214-
// "Call py::type::handle_of(h) or py::type::of(h) instead of h.get_type()")
213+
PYBIND11_DEPRECATED("Call py::type::handle_of(h) or py::type::of(h) instead of h.get_type()")
215214
handle get_type() const;
216215

217216
private:

tests/test_class.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ TEST_SUBMODULE(class_, m) {
219219

220220
m.def("get_type_of", [](py::object ob) { return py::type::of(std::move(ob)); });
221221

222-
m.def("get_type_classic", [](py::handle h) { return h.get_type(); });
222+
m.def("get_type_classic", [](py::handle h) { return py::type::handle_of(h); });
223223

224224
m.def("as_type", [](const py::object &ob) { return py::type(ob); });
225225

0 commit comments

Comments
 (0)