diff --git a/mlir/lib/Bindings/Python/DialectTransform.cpp b/mlir/lib/Bindings/Python/DialectTransform.cpp --- a/mlir/lib/Bindings/Python/DialectTransform.cpp +++ b/mlir/lib/Bindings/Python/DialectTransform.cpp @@ -53,7 +53,7 @@ [](MlirType type) { MlirStringRef operationName = mlirTransformOperationTypeGetOperationName(type); - return py::str(operationName.data, operationName.length); + return py::bytes(operationName.data, operationName.length); }, "Get the name of the payload operation accepted by the handle."); } diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp --- a/mlir/lib/Bindings/Python/IRAttributes.cpp +++ b/mlir/lib/Bindings/Python/IRAttributes.cpp @@ -453,9 +453,9 @@ "value", [](PyFlatSymbolRefAttribute &self) { MlirStringRef stringRef = mlirFlatSymbolRefAttrGetValue(self); - return py::str(stringRef.data, stringRef.length); + return py::bytes(stringRef.data, stringRef.length); }, - "Returns the value of the FlatSymbolRef attribute as a string"); + "Returns the value of the FlatSymbolRef attribute as `bytes`"); } }; @@ -483,16 +483,16 @@ "dialect_namespace", [](PyOpaqueAttribute &self) { MlirStringRef stringRef = mlirOpaqueAttrGetDialectNamespace(self); - return py::str(stringRef.data, stringRef.length); + return py::bytes(stringRef.data, stringRef.length); }, - "Returns the dialect namespace for the Opaque attribute as a string"); + "Returns the dialect namespace for the Opaque attribute as `bytes`"); c.def_property_readonly( "data", [](PyOpaqueAttribute &self) { MlirStringRef stringRef = mlirOpaqueAttrGetData(self); - return py::str(stringRef.data, stringRef.length); + return py::bytes(stringRef.data, stringRef.length); }, - "Returns the data for the Opaqued attributes as a string"); + "Returns the data for the Opaqued attributes as `bytes`"); } }; @@ -525,9 +525,9 @@ "value", [](PyStringAttribute &self) { MlirStringRef stringRef = mlirStringAttrGetValue(self); - return py::str(stringRef.data, stringRef.length); + return py::bytes(stringRef.data, stringRef.length); }, - "Returns the value of the string attribute"); + "Returns the value of the string attribute as `bytes`"); } }; diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp --- a/mlir/lib/Bindings/Python/IRCore.cpp +++ b/mlir/lib/Bindings/Python/IRCore.cpp @@ -2431,7 +2431,7 @@ [](PyDialectDescriptor &self) { MlirStringRef ns = mlirDialectGetNamespace(self.get()); - return py::str(ns.data, ns.length); + return py::bytes(ns.data, ns.length); }) .def("__repr__", [](PyDialectDescriptor &self) { MlirStringRef ns = mlirDialectGetNamespace(self.get()); @@ -2823,7 +2823,7 @@ MlirOperation operation = self.get(); MlirStringRef name = mlirIdentifierStr( mlirOperationGetName(operation)); - return py::str(name.data, name.length); + return py::bytes(name.data, name.length); }) .def_property_readonly( "context", @@ -3174,8 +3174,8 @@ PyPrintAccumulator printAccum; printAccum.parts.append("NamedAttribute("); printAccum.parts.append( - py::str(mlirIdentifierStr(self.namedAttr.name).data, - mlirIdentifierStr(self.namedAttr.name).length)); + py::bytes(mlirIdentifierStr(self.namedAttr.name).data, + mlirIdentifierStr(self.namedAttr.name).length)); printAccum.parts.append("="); mlirAttributePrint(self.namedAttr.attribute, printAccum.getCallback(), @@ -3186,8 +3186,8 @@ .def_property_readonly( "name", [](PyNamedAttribute &self) { - return py::str(mlirIdentifierStr(self.namedAttr.name).data, - mlirIdentifierStr(self.namedAttr.name).length); + return py::bytes(mlirIdentifierStr(self.namedAttr.name).data, + mlirIdentifierStr(self.namedAttr.name).length); }, "The name of the NamedAttribute binding") .def_property_readonly( diff --git a/mlir/lib/Bindings/Python/IRTypes.cpp b/mlir/lib/Bindings/Python/IRTypes.cpp --- a/mlir/lib/Bindings/Python/IRTypes.cpp +++ b/mlir/lib/Bindings/Python/IRTypes.cpp @@ -696,16 +696,16 @@ "dialect_namespace", [](PyOpaqueType &self) { MlirStringRef stringRef = mlirOpaqueTypeGetDialectNamespace(self); - return py::str(stringRef.data, stringRef.length); + return py::bytes(stringRef.data, stringRef.length); }, - "Returns the dialect namespace for the Opaque type as a string."); + "Returns the dialect namespace for the Opaque type as `bytes`."); c.def_property_readonly( "data", [](PyOpaqueType &self) { MlirStringRef stringRef = mlirOpaqueTypeGetData(self); - return py::str(stringRef.data, stringRef.length); + return py::bytes(stringRef.data, stringRef.length); }, - "Returns the data for the Opaque type as a string."); + "Returns the data for the Opaque type as `bytes`."); } };