From e289e0ea24c27419a67274e8de80b270b6dafd27 Mon Sep 17 00:00:00 2001 From: Sergei Lebedev Date: Wed, 28 Aug 2019 11:30:55 +0100 Subject: [PATCH] Do not attempt to normalize if no exception occurred This is not supported on PyPy-2.7 5.8.0. --- include/pybind11/pytypes.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index f8ca00b33..76e915cca 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -335,7 +335,8 @@ public: virtual const char* what() const noexcept { if (m_lazy_what.empty()) { - PyErr_NormalizeException(&m_type.ptr(), &m_value.ptr(), &m_trace.ptr()); + if (m_type || m_value || m_trace) + PyErr_NormalizeException(&m_type.ptr(), &m_value.ptr(), &m_trace.ptr()); m_lazy_what = detail::error_string(m_type.ptr(), m_value.ptr(), m_trace.ptr()); } return m_lazy_what.c_str();