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

Stella Laurenzo llvmlistbot at llvm.org
Wed Dec 11 19:53:09 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:

The temporary result of py::repr is kept alive through the operator application, right? (I usually avoid this idiom because then I don't have to think about c++ temporary lifetime extension rules)

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


More information about the Mlir-commits mailing list