From c935b73ba563f1db9aeb9fb06da6ef040d2ce682 Mon Sep 17 00:00:00 2001 From: Sergei Lebedev Date: Wed, 28 Aug 2019 18:53:35 +0100 Subject: [PATCH] Revert "Extract exception name via tp_name" The implementation of __name__ is slightly more complex than that. It handles the module name prefix, and heap-allocated types. We could port it to pybind11 later on but for now it seems like an overkill. This reverts commit f1435c7e6b068a1ed13ebd3db597ea3bb15aa398. --- include/pybind11/cast.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index c02708195..8bcf81761 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -413,7 +413,7 @@ PYBIND11_NOINLINE inline std::string error_string(PyObject* type, PyObject* valu // normalized by the caller? std::string errorString; if (type) { - errorString += static_cast(reinterpret_cast(type)->tp_name); + errorString += handle(type).attr("__name__").cast(); errorString += ": "; } if (value)