Author: Tulio Magno Quites Machado Filho Date: 2023-10-31T17:08:55-03:00 New Revision: 2260ebf7b6df15db96c76039758dd9dbf009c334
URL: https://github.com/llvm/llvm-project/commit/2260ebf7b6df15db96c76039758dd9dbf009c334 DIFF: https://github.com/llvm/llvm-project/commit/2260ebf7b6df15db96c76039758dd9dbf009c334.diff LOG: [lldb] Replace the usage of module imp with module importlib (#70443) imp got removed in Python 3.12 [1] and the community recommends using importlib in newer Python versions. [1] https://docs.python.org/3.12/whatsnew/3.12.html#imp Added: Modified: lldb/scripts/use_lldb_suite.py lldb/test/API/use_lldb_suite.py Removed: ################################################################################ diff --git a/lldb/scripts/use_lldb_suite.py b/lldb/scripts/use_lldb_suite.py index 6388d87b181ce03..a050db0e79e6807 100644 --- a/lldb/scripts/use_lldb_suite.py +++ b/lldb/scripts/use_lldb_suite.py @@ -17,11 +17,12 @@ def find_lldb_root(): lldb_root = find_lldb_root() -import imp -fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root]) -try: - imp.load_module("use_lldb_suite_root", fp, pathname, desc) -finally: - if fp: - fp.close() +import importlib.machinery +import importlib.util + +path = os.path.join(lldb_root, "use_lldb_suite_root.py") +loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path) +spec = importlib.util.spec_from_loader("use_lldb_suite_root", loader=loader) +module = importlib.util.module_from_spec(spec) +loader.exec_module(module) diff --git a/lldb/test/API/use_lldb_suite.py b/lldb/test/API/use_lldb_suite.py index e237dd4b8a5607c..a680f8c466a34f0 100644 --- a/lldb/test/API/use_lldb_suite.py +++ b/lldb/test/API/use_lldb_suite.py @@ -20,11 +20,11 @@ def find_lldb_root(): lldb_root = find_lldb_root() -import imp +import importlib.machinery +import importlib.util -fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root]) -try: - imp.load_module("use_lldb_suite_root", fp, pathname, desc) -finally: - if fp: - fp.close() +path = os.path.join(lldb_root, "use_lldb_suite_root.py") +loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path) +spec = importlib.util.spec_from_loader("use_lldb_suite_root", loader=loader) +module = importlib.util.module_from_spec(spec) +loader.exec_module(module) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits