[Mlir-commits] [mlir] b2bdc45 - [mlir][python] Fix possible use of variable use before set
Mehdi Amini
llvmlistbot at llvm.org
Tue Oct 31 10:31:28 PDT 2023
Author: Mehdi Amini
Date: 2023-10-31T10:31:20-07:00
New Revision: b2bdc45580e04c86571a355b17bf406993eceebc
URL: https://github.com/llvm/llvm-project/commit/b2bdc45580e04c86571a355b17bf406993eceebc
DIFF: https://github.com/llvm/llvm-project/commit/b2bdc45580e04c86571a355b17bf406993eceebc.diff
LOG: [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
Added:
Modified:
mlir/python/mlir/_mlir_libs/__init__.py
Removed:
################################################################################
diff --git a/mlir/python/mlir/_mlir_libs/__init__.py b/mlir/python/mlir/_mlir_libs/__init__.py
index 71c074bc955e8c3..d5fc447e49bf3a6 100644
--- a/mlir/python/mlir/_mlir_libs/__init__.py
+++ b/mlir/python/mlir/_mlir_libs/__init__.py
@@ -83,6 +83,7 @@ def process_initializer_module(module_name):
# 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__)
More information about the Mlir-commits
mailing list