diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp index 045c0fbf4630f..c0a945e3f4f3b 100644 --- a/mlir/lib/Bindings/Python/IRAttributes.cpp +++ b/mlir/lib/Bindings/Python/IRAttributes.cpp @@ -1306,6 +1306,10 @@ PyType_Slot PyDenseElementsAttribute::slots[] = { e.restore(); nb::chain_error(PyExc_BufferError, "Error converting attribute to buffer"); return -1; + } catch (std::exception &e) { + nb::chain_error(PyExc_BufferError, + "Error converting attribute to buffer: %s", e.what()); + return -1; } view->obj = obj; view->ndim = 1;