File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,14 @@ void mlir::python::populatePassManagerSubmodule(nb::module_ &m) {
196196 nb::delattr (callable, mlirExternalPassAttr);
197197 };
198198 nb::setattr (run, " signal_pass_failure" , nb::cpp_function ([run]() {
199- nb::capsule cap = run.attr (mlirExternalPassAttr);
199+ nb::capsule cap;
200+ try {
201+ cap = run.attr (mlirExternalPassAttr);
202+ } catch (nb::python_error &e) {
203+ throw std::runtime_error (
204+ " signal_pass_failure() should always be called "
205+ " from the __call__ method" );
206+ }
200207 mlirExternalPassSignalFailure (
201208 MlirExternalPass{cap.data ()});
202209 }));
Original file line number Diff line number Diff line change @@ -103,3 +103,9 @@ def __call__(self, m):
103103 pm .run (module )
104104 except Exception as e :
105105 print (f"caught exception: { e } " )
106+
107+ # CHECK: caught exception: signal_pass_failure() should always be called from the __call__ method
108+ try :
109+ custom_pass_that_fails .signal_pass_failure ()
110+ except Exception as e :
111+ print (f"caught exception: { e } " )
You can’t perform that action at this time.
0 commit comments