Skip to content

[lldb] Replace the usage of module imp with module importlib #70443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lldb/scripts/use_lldb_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 7 additions & 7 deletions lldb/test/API/use_lldb_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)