Skip to content

[Dexter] Set up ComInterface module to be imported correctly #111850

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 10, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
def _load_com_module():
try:
return load_module(
"ComInterface", os.path.join(os.path.dirname(__file__), "windows")
"ComInterface",
os.path.join(os.path.dirname(__file__), "windows"),
"ComInterface.py",
)
except ImportError as e:
raise LoadDebuggerException(e, sys.exc_info())
Expand Down
13 changes: 9 additions & 4 deletions cross-project-tests/debuginfo-tests/dexter/dex/utils/Imports.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import importlib
import importlib.util
import os
import sys


def load_module(name, path):
spec = importlib.util.spec_from_file_location(
name, os.path.join(path, name, "__init__.py")
def load_module(name, path, mod_file="__init__.py"):
# The module is either defined by a directory, in which case we search for
# `path/name/__init__.py`, or it is a single file at `path/mod_file`.
mod_path = (
os.path.join(path, name, mod_file)
if mod_file == "__init__.py"
else os.path.join(path, mod_file)
)
spec = importlib.util.spec_from_file_location(name, mod_path)
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
Expand Down
Loading