diff --git a/example/issues.cpp b/example/issues.cpp index e1647081f..2225226fb 100644 --- a/example/issues.cpp +++ b/example/issues.cpp @@ -131,4 +131,25 @@ void init_issues(py::module &m) { .def("f", &A::f); m2.def("call_f", call_f); + + { + struct DuplicateFoo { + int id() const { return 1; } + }; + + struct SingularBar : public DuplicateFoo { + }; + + pybind11::class_(m2, "DuplicateFoo") + .def_property_readonly("id", &DuplicateFoo::id) + ; + + pybind11::class_(m2, "SingularBar") + .def(pybind11::init<>()) + ; + + // Second time registration + pybind11::class_(m2, "DuplicateFoo") + ; + } } diff --git a/example/issues.py b/example/issues.py index 257f08e18..71cd088f3 100644 --- a/example/issues.py +++ b/example/issues.py @@ -10,6 +10,7 @@ from example.issues import iterator_passthrough from example.issues import ElementList, ElementA, print_element from example.issues import expect_float, expect_int from example.issues import A, call_f +from example.issues import SingularBar import gc print_cchar("const char *") @@ -72,3 +73,9 @@ print("Python version") b = B() call_f(b) +singularBar = SingularBar() +try: + singularBar.id +except Exception as e: + print("Failed as expected: " + str(e)) + diff --git a/example/issues.ref b/example/issues.ref index 58cc7985f..d5448a68f 100644 --- a/example/issues.ref +++ b/example/issues.ref @@ -18,3 +18,4 @@ Python version PyA.PyA() PyA.f() In python f() +Failed as expected: 'issues.SingularBar' object has no attribute 'id'