From c264cab831131a408b2adf179028b120663e84fd Mon Sep 17 00:00:00 2001 From: Bryn Lloyd <12702862+dyollb@users.noreply.github.com> Date: Wed, 23 Apr 2025 09:11:35 +0200 Subject: [PATCH] demo issue occuring in pybind11-stubgen --- tests/test_class.cpp | 7 +++++++ tests/test_pytypes.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/tests/test_class.cpp b/tests/test_class.cpp index 3d567fc1f5..f8df426663 100644 --- a/tests/test_class.cpp +++ b/tests/test_class.cpp @@ -60,6 +60,10 @@ class Args : public py::args {}; } // namespace test_class +namespace { +class Foo {}; +} // namespace + static_assert(py::detail::is_same_or_base_of::value, ""); static_assert( py::detail::is_same_or_base_of(m, "Foo"); } template diff --git a/tests/test_pytypes.cpp b/tests/test_pytypes.cpp index cbbf42178b..c3101eed7a 100644 --- a/tests/test_pytypes.cpp +++ b/tests/test_pytypes.cpp @@ -177,6 +177,10 @@ struct type_caster { } // namespace detail } // namespace pybind11 +namespace { +class Foo {}; +} // namespace + TEST_SUBMODULE(pytypes, m) { m.def("obj_class_name", [](py::handle obj) { return py::detail::obj_class_name(obj.ptr()); }); @@ -1206,4 +1210,7 @@ TEST_SUBMODULE(pytypes, m) { m.def("check_type_is", [](const py::object &x) -> py::typing::TypeIs { return py::isinstance(x); }); + + // test register different classes with same name (in anonymous namespace) + py::class_(m, "Foo"); }