[Mlir-commits] [mlir] [mlir][py] avoid crashing on None contexts in custom `get`s (PR #171140)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Tue Dec 9 23:27:03 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:
----------------
ftynse wrote:
Yep, its reasoning is that if a type caster fails, it's a type error.
https://github.com/llvm/llvm-project/pull/171140
More information about the Mlir-commits
mailing list