From b90bd783f04d0956c287781a561dcc571e61738e Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Tue, 22 Feb 2022 11:10:10 -0500 Subject: [PATCH] Add noexcept move and explicit fail throw --- include/pybind11/pytypes.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index 3fdaa46de..b4798cc75 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -391,7 +391,7 @@ public: } error_already_set(const error_already_set &) = default; - error_already_set(error_already_set &&) = default; + error_already_set(error_already_set &&) noexcept = default; inline ~error_already_set() override; @@ -419,6 +419,9 @@ public: /// error variables (but the `.what()` string is still available). void restore() { what(); // Force-build `.what()`. + if (m_lazy_what.empty()) { + pybind11_fail("Critical error building lazy error_string()."); + } if (m_type) { PyErr_Restore( m_type.release().ptr(), m_value.release().ptr(), m_trace.release().ptr());