Skip to content

Commit 8275a6a

Browse files
committed
Addressed PR review comments
1 parent 6e3f68e commit 8275a6a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/test_exceptions.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,9 @@ TEST_SUBMODULE(exceptions, m) {
405405
.def(py::init<const std::string &>())
406406
.def_readwrite("a", &CustomData::a);
407407

408-
PYBIND11_CONSTINIT static py::gil_safe_call_once_and_store<py::object> storage;
409-
storage.call_once_and_store_result([&]() {
408+
PYBIND11_CONSTINIT static py::gil_safe_call_once_and_store<py::object>
409+
PythonMyException7_storage;
410+
PythonMyException7_storage.call_once_and_store_result([&]() {
410411
auto mod = py::module_::import("custom_exceptions");
411412
py::object obj = mod.attr("PythonMyException7");
412413
return obj;
@@ -418,9 +419,9 @@ TEST_SUBMODULE(exceptions, m) {
418419
std::rethrow_exception(p);
419420
}
420421
} catch (const MyException7 &e) {
421-
auto obj = storage.get_stored();
422-
py::object obj2 = obj(e.message);
423-
PyErr_SetObject(PyExc_Exception, obj2.ptr());
422+
auto exc_type = PythonMyException7_storage.get_stored();
423+
py::object exc_inst = exc_type(e.message);
424+
PyErr_SetObject(PyExc_Exception, exc_inst.ptr());
424425
}
425426
});
426427
}

0 commit comments

Comments
 (0)