@@ -2250,29 +2250,13 @@ static void populateIRCore(nb::module_ &m) {
22502250
22512251 // Attribute builder getter.
22522252 PyAttrBuilderMap::bind (m);
2253-
2254- // nb::register_exception_translator([](const std::exception_ptr &p,
2255- // void *payload) {
2256- // // We can't define exceptions with custom fields through pybind, so
2257- // instead
2258- // // the exception class is defined in python and imported here.
2259- // try {
2260- // if (p)
2261- // std::rethrow_exception(p);
2262- // } catch (const MLIRError &e) {
2263- // nb::object obj = nb::module_::import_(MAKE_MLIR_PYTHON_QUALNAME("ir"))
2264- // .attr("MLIRError")(e.message, e.errorDiagnostics);
2265- // PyErr_SetObject(PyExc_Exception, obj.ptr());
2266- // }
2267- // });
22682253}
22692254
22702255namespace mlir ::python {
22712256void populateIRAffine (nb::module_ &m);
22722257void populateIRAttributes (nb::module_ &m);
22732258void populateIRInterfaces (nb::module_ &m);
22742259void populateIRTypes (nb::module_ &m);
2275- void registerMLIRErrorInIRCore ();
22762260} // namespace mlir::python
22772261
22782262// -----------------------------------------------------------------------------
@@ -2415,18 +2399,6 @@ NB_MODULE(_mlir, m) {
24152399 auto passManagerModule =
24162400 m.def_submodule (" passmanager" , " MLIR Pass Management Bindings" );
24172401 populatePassManagerSubmodule (passManagerModule);
2418- registerMLIRErrorInIRCore ();
2419- nb::register_exception_translator ([](const std::exception_ptr &p,
2420- void *payload) {
2421- // We can't define exceptions with custom fields through pybind, so
2422- // instead the exception class is defined in python and imported here.
2423- try {
2424- if (p)
2425- std::rethrow_exception (p);
2426- } catch (const MLIRError &e) {
2427- nb::object obj = nb::module_::import_ (MAKE_MLIR_PYTHON_QUALNAME (" ir" ))
2428- .attr (" MLIRError" )(e.message , e.errorDiagnostics );
2429- PyErr_SetObject (PyExc_Exception, obj.ptr ());
2430- }
2431- });
2402+ registerMLIRError ();
2403+ registerMLIRErrorInCore ();
24322404}
0 commit comments