Try to debug PGI

This commit is contained in:
Aaron Gokaslan 2022-02-15 12:16:18 -05:00
parent 63dfbb436e
commit d231f15996
2 changed files with 12 additions and 2 deletions

View File

@ -479,7 +479,7 @@ PYBIND11_NOINLINE std::string error_string(PyObject *type, PyObject *value, PyOb
result += ": "; result += ": ";
if (value) { if (value) {
result += str(value).cast<std::string>(); result += (std::string) str(value);
} }
if (trace) { if (trace) {
@ -517,6 +517,9 @@ PYBIND11_NOINLINE std::string error_string() {
error_scope scope; // Preserve error state. error_scope scope; // Preserve error state.
if (scope.type) { if (scope.type) {
PyErr_NormalizeException(&scope.type, &scope.value, &scope.trace); PyErr_NormalizeException(&scope.type, &scope.value, &scope.trace);
/*if (scope.trace != nullptr){
PyErr_SetTraceback(scope.value, scope.trace);
}*/
} }
return error_string(scope.type, scope.value, scope.trace); return error_string(scope.type, scope.value, scope.trace);
} }

View File

@ -12,6 +12,7 @@
#include "detail/common.h" #include "detail/common.h"
#include "buffer_info.h" #include "buffer_info.h"
#include <exception>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
@ -397,9 +398,15 @@ public:
inline ~error_already_set() override; inline ~error_already_set() override;
const char *what() const noexcept override { const char *what() const noexcept override {
if (m_lazy_what.empty() && m_type) { if (m_lazy_what.empty()) {
try { try {
m_lazy_what = detail::error_string(m_type.ptr(), m_value.ptr(), m_trace.ptr()); m_lazy_what = detail::error_string(m_type.ptr(), m_value.ptr(), m_trace.ptr());
} catch (const std::exception &e) {
m_lazy_what
= std::string(
"Unknown internal error occurred while constructing error_string:")
+ e.what();
return m_lazy_what.c_str();
} catch (...) { } catch (...) {
m_lazy_what = "Unknown internal error occurred"; m_lazy_what = "Unknown internal error occurred";
} }