[Mlir-commits] [llvm] [mlir] [mlir python] Port Python core code to nanobind. (PR #118583)

Stella Laurenzo llvmlistbot at llvm.org
Thu Dec 12 12:09:31 PST 2024


================
@@ -708,8 +843,8 @@ class PyDenseElementsAttribute
         std::string message;
         llvm::raw_string_ostream os(message);
         os << "Expected a static ShapedType for the shaped_type parameter: "
-           << py::repr(py::cast(*explicitType));
-        throw py::value_error(message);
+           << nb::cast<std::string_view>(nb::repr(nb::cast(*explicitType)));
----------------
stellaraccident wrote:

Ok, that's usually how I end up back at this point. Since these are all exception messages and presumably not performance critical (and also don't always get the best testing), let's be conservative/safe with std::string, unless if one of the c++ gurus which can sometimes be found in these parts says it is ok.

https://github.com/llvm/llvm-project/pull/118583


More information about the Mlir-commits mailing list