[mlir][python] Fix possible use of variable use before set

The _mlirRegisterEverything symbol may not be built by some customers. The
code here was intended to support this, but didn't properly initialize the
init_module variable.
This would break JAX with:

NameError: free variable 'init_module' referenced before assignment in enclosing scope
This commit is contained in:
Mehdi Amini 2023-10-31 10:29:29 -07:00
parent a3ee0d4fac
commit b2bdc45580

View File

@ -83,6 +83,7 @@ def _site_initialize():
# If _mlirRegisterEverything is built, then include it as an initializer
# module.
init_module = None
if process_initializer_module("_mlirRegisterEverything"):
init_module = importlib.import_module(f"._mlirRegisterEverything", __name__)