Change error_already_set() to call pybind11_fail() if the Python error indicator not set. The net result is that a std::runtime_error is thrown instead of error_already_set, but all tests pass as is.

This commit is contained in:
Ralf W. Grosse-Kunstleve 2022-05-11 23:59:14 -07:00
parent dded0243a4
commit 4193375ed6

View File

@ -391,9 +391,8 @@ public:
/// RuntimeError("Internal error: ..."). The current Python error indicator will be cleared.
error_already_set() : std::runtime_error("") {
if (!PyErr_Occurred()) {
m_lazy_what = "Internal error: pybind11::detail::error_already_set called while "
"Python error indicator not set.";
PyErr_SetString(PyExc_RuntimeError, m_lazy_what.c_str());
pybind11_fail("Internal error: pybind11::detail::error_already_set called while "
"Python error indicator not set.");
}
PyErr_Fetch(&m_type.ptr(), &m_value.ptr(), &m_trace.ptr());
PyErr_NormalizeException(&m_type.ptr(), &m_value.ptr(), &m_trace.ptr());