fix: type bug intruduced in #2492
This now tests the old form too, and fixes the bug introduced.
diff --git a/tests/test_class.cpp b/tests/test_class.cpp
index b0e3d3a..bb9d364 100644
--- a/tests/test_class.cpp
+++ b/tests/test_class.cpp
@@ -152,6 +152,10 @@
return py::type::of(ob);
});
+ m.def("get_type_classic", [](py::handle h) {
+ return h.get_type();
+ });
+
m.def("as_type", [](py::object ob) {
auto tp = py::type(ob);
if (py::isinstance<py::type>(ob))
diff --git a/tests/test_class.py b/tests/test_class.py
index be21f37..64f4941 100644
--- a/tests/test_class.py
+++ b/tests/test_class.py
@@ -45,6 +45,12 @@
assert m.get_type_of(int) == type
+def test_type_of_classic():
+ assert m.get_type_classic(1) == int
+ assert m.get_type_classic(m.DerivedClass1()) == m.DerivedClass1
+ assert m.get_type_classic(int) == type
+
+
def test_type_of_py_nodelete():
# If the above test deleted the class, this will segfault
assert m.get_type_of(m.DerivedClass1()) == m.DerivedClass1