mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-19 22:39:09 +00:00
Add error_scope to py::class_::dealloc() to protect destructor calls (#2342)
Fixes issue #1878
This commit is contained in:
@@ -379,6 +379,17 @@ TEST_SUBMODULE(class_, m) {
|
||||
// test_non_final_final
|
||||
struct IsNonFinalFinal {};
|
||||
py::class_<IsNonFinalFinal>(m, "IsNonFinalFinal", py::is_final());
|
||||
|
||||
struct PyPrintDestructor {
|
||||
PyPrintDestructor() {}
|
||||
~PyPrintDestructor() {
|
||||
py::print("Print from destructor");
|
||||
}
|
||||
void throw_something() { throw std::runtime_error("error"); }
|
||||
};
|
||||
py::class_<PyPrintDestructor>(m, "PyPrintDestructor")
|
||||
.def(py::init<>())
|
||||
.def("throw_something", &PyPrintDestructor::throw_something);
|
||||
}
|
||||
|
||||
template <int N> class BreaksBase { public:
|
||||
|
||||
Reference in New Issue
Block a user