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

Maksim Levental llvmlistbot at llvm.org
Fri Jul 11 08:56:47 PDT 2025


makslevental wrote:

> Thanks! I started checking the casts, and found two more `nanobind::cast<MlirTypeID>` in `lib/Bindings/Python/IRModule.h`:

Yea I saw these and I think they're safe according to exact your same logic. 

> It might also be necessary to check some of the other nanobind::cast(v) calls though, where v is some C++ type convertible to a MlirSOMETHING.

Yup those are exactly the ones I was worried about. Note though (I believe!) any of the casts like `nanobind::cast<PySOMETHING>()` should be safe because they do not go through an intermediate `MlirSOMETHING` step.

Also btw we're gonna need a PSA about this because it's a breaking change (even though it's a fix) for downstream projects.

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


More information about the Mlir-commits mailing list