[all-commits] [llvm/llvm-project] 6a12b7: [mlir][python] Fix Python binding cast diagnostics...

Maksim Levental via All-commits all-commits at lists.llvm.org
Sun Jun 28 21:06:15 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6a12b7c74b179fbd1b40466f57d94dd8ed53cf16
      https://github.com/llvm/llvm-project/commit/6a12b7c74b179fbd1b40466f57d94dd8ed53cf16
  Author: Maksim Levental <maksim.levental at gmail.com>
  Date:   2026-06-28 (Sun, 28 Jun 2026)

  Changed paths:
    M mlir/include/mlir/Bindings/Python/IRAttributes.h
    M mlir/lib/Bindings/Python/IRAffine.cpp
    M mlir/lib/Bindings/Python/IRCore.cpp

  Log Message:
  -----------
  [mlir][python] Fix Python binding cast diagnostics for nanobind 2.13 (#206391)

nanobind 2.13.0 changed failing `nb::cast<T>()` to raise `cast_error`
(an alias for `std::bad_cast`) for all failures, including `None`,
instead of the previous distinct exception types. The bindings relied on
catching `std::runtime_error` separately from `cast_error` to emit a
helpful "(None?)" hint, so that branch became dead code and the `None`
diagnostics regressed (e.g. "(std::bad_cast)" instead of "(None?)"),
breaking check-mlir Python tests.

Fix: Decide the `None` hint from the value via `is_none()` rather than
the exception type. This is robust across nanobind versions (2.10-2.13).

Fixes #205329 

Assisted by: Claude



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list