mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 07:02:11 +00:00
New issue, when registering type multiple times.
Ideally, the module should fail when loading IMO.
This commit is contained in:
parent
5eda97d7e4
commit
e90bf7cc06
@ -131,4 +131,25 @@ void init_issues(py::module &m) {
|
|||||||
.def("f", &A::f);
|
.def("f", &A::f);
|
||||||
|
|
||||||
m2.def("call_f", call_f);
|
m2.def("call_f", call_f);
|
||||||
|
|
||||||
|
{
|
||||||
|
struct DuplicateFoo {
|
||||||
|
int id() const { return 1; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SingularBar : public DuplicateFoo {
|
||||||
|
};
|
||||||
|
|
||||||
|
pybind11::class_<DuplicateFoo>(m2, "DuplicateFoo")
|
||||||
|
.def_property_readonly("id", &DuplicateFoo::id)
|
||||||
|
;
|
||||||
|
|
||||||
|
pybind11::class_<SingularBar>(m2, "SingularBar")
|
||||||
|
.def(pybind11::init<>())
|
||||||
|
;
|
||||||
|
|
||||||
|
// Second time registration
|
||||||
|
pybind11::class_<DuplicateFoo>(m2, "DuplicateFoo")
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ from example.issues import iterator_passthrough
|
|||||||
from example.issues import ElementList, ElementA, print_element
|
from example.issues import ElementList, ElementA, print_element
|
||||||
from example.issues import expect_float, expect_int
|
from example.issues import expect_float, expect_int
|
||||||
from example.issues import A, call_f
|
from example.issues import A, call_f
|
||||||
|
from example.issues import SingularBar
|
||||||
import gc
|
import gc
|
||||||
|
|
||||||
print_cchar("const char *")
|
print_cchar("const char *")
|
||||||
@ -72,3 +73,9 @@ print("Python version")
|
|||||||
b = B()
|
b = B()
|
||||||
call_f(b)
|
call_f(b)
|
||||||
|
|
||||||
|
singularBar = SingularBar()
|
||||||
|
try:
|
||||||
|
singularBar.id
|
||||||
|
except Exception as e:
|
||||||
|
print("Failed as expected: " + str(e))
|
||||||
|
|
||||||
|
@ -18,3 +18,4 @@ Python version
|
|||||||
PyA.PyA()
|
PyA.PyA()
|
||||||
PyA.f()
|
PyA.f()
|
||||||
In python f()
|
In python f()
|
||||||
|
Failed as expected: 'issues.SingularBar' object has no attribute 'id'
|
||||||
|
Loading…
Reference in New Issue
Block a user