Skip to content

Commit

Permalink
Addressed PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vfdev-5 committed Sep 16, 2024
1 parent 6e3f68e commit 8275a6a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/test_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@ TEST_SUBMODULE(exceptions, m) {
.def(py::init<const std::string &>())
.def_readwrite("a", &CustomData::a);

PYBIND11_CONSTINIT static py::gil_safe_call_once_and_store<py::object> storage;
storage.call_once_and_store_result([&]() {
PYBIND11_CONSTINIT static py::gil_safe_call_once_and_store<py::object>
PythonMyException7_storage;
PythonMyException7_storage.call_once_and_store_result([&]() {
auto mod = py::module_::import("custom_exceptions");
py::object obj = mod.attr("PythonMyException7");
return obj;
Expand All @@ -418,9 +419,9 @@ TEST_SUBMODULE(exceptions, m) {
std::rethrow_exception(p);
}
} catch (const MyException7 &e) {
auto obj = storage.get_stored();
py::object obj2 = obj(e.message);
PyErr_SetObject(PyExc_Exception, obj2.ptr());
auto exc_type = PythonMyException7_storage.get_stored();
py::object exc_inst = exc_type(e.message);
PyErr_SetObject(PyExc_Exception, exc_inst.ptr());
}
});
}

0 comments on commit 8275a6a

Please sign in to comment.