[Mlir-commits] [mlir] [mlir][py] avoid crashing on None contexts in custom `get`s (PR #171140)
Maksim Levental
llvmlistbot at llvm.org
Mon Dec 8 08:03:30 PST 2025
================
@@ -148,3 +148,16 @@ def test_value_type():
print(parsedType)
# CHECK: !pdl.value
print(constructedType)
+
+
+# CHECK-LABEL: TEST: test_type_without_context
+ at run
+def test_type_without_context():
+ # Constructing a type without the surrounding ir.Context context manager
+ # should raise an exception but not crash.
+ try:
+ constructedType = pdl.ValueType.get()
+ except TypeError:
----------------
makslevental wrote:
nit: this is the wrong error - it should be `RuntimeError` - but I guess nanobind is making the choice here not us 🤷
https://github.com/llvm/llvm-project/pull/171140
More information about the Mlir-commits
mailing list