From 91bf33f459eee9877cf722f245f6f20d5d128280 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Tue, 15 Feb 2022 11:30:06 -0500 Subject: [PATCH] guard if m_type is null --- include/pybind11/pytypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index a4ccb3741..fec563208 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -397,7 +397,7 @@ public: inline ~error_already_set() override; const char *what() const noexcept override { - if (m_lazy_what.empty()) { + if (m_lazy_what.empty() && m_type) { try { m_lazy_what = detail::error_string(m_type.ptr(), m_value.ptr(), m_trace.ptr()); } catch (...) {