mirror of
https://github.com/pybind/pybind11.git
synced 2026-06-06 06:11:25 +00:00
Move PyErr_NormalizeException() up a few lines (#3971)
* Add error_already_set_what what tests, asserting the status quo.
* Move PyErr_NormalizeException() up a few lines.
* @pytest.mark.skipif("env.PYPY") from PR #1895 is required even for this much simpler PR
* Move PyException_SetTraceback() with PyErr_NormalizeException() as suggested by @skylion007
* Insert a std::move() as suggested by @skylion007
This commit is contained in:
committed by
GitHub
parent
2d4a20c8cb
commit
2c549eb7aa
@@ -299,4 +299,12 @@ TEST_SUBMODULE(exceptions, m) {
|
||||
std::throw_with_nested(std::runtime_error("Outer Exception"));
|
||||
}
|
||||
});
|
||||
|
||||
m.def("error_already_set_what", [](const py::object &exc_type, const py::object &exc_value) {
|
||||
PyErr_SetObject(exc_type.ptr(), exc_value.ptr());
|
||||
std::string what = py::error_already_set().what();
|
||||
bool py_err_set_after_what = (PyErr_Occurred() != nullptr);
|
||||
PyErr_Clear();
|
||||
return py::make_tuple(std::move(what), py_err_set_after_what);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user