[Mlir-commits] [mlir] [mlir][py] Mark all type caster `from_{cpp, python}` methods as noexcept (PR #143866)

Maksim Levental llvmlistbot at llvm.org
Thu Jul 10 08:06:25 PDT 2025


================
@@ -68,11 +65,10 @@ template <>
 struct type_caster<MlirAffineMap> {
   NB_TYPE_CASTER(MlirAffineMap, const_name("MlirAffineMap"))
   bool from_python(handle src, uint8_t flags, cleanup_list *cleanup) noexcept {
-    nanobind::object capsule = mlirApiObjectToCapsule(src);
-    value = mlirPythonCapsuleToAffineMap(capsule.ptr());
-    if (mlirAffineMapIsNull(value)) {
+    std::optional<nanobind::object> capsule = mlirApiObjectToCapsule(src);
+    if (!capsule)
----------------
makslevental wrote:

I did

```c++
    if (auto capsule = mlirApiObjectToCapsule(src))
      value = mlirPythonCapsuleToPassManager(capsule->ptr());
```

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


More information about the Mlir-commits mailing list