Skip to content
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

Use import_module instead of find_spec #39423

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
10 changes: 3 additions & 7 deletions src/sage/misc/dev_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
"""
from .package_dir import walk_packages
import importlib.util
import importlib

if module is None:
import sage
Expand All @@ -195,12 +195,8 @@ def load_submodules(module=None, exclude_pattern=None):
try:
sys.stdout.write("load %s..." % module_name)
sys.stdout.flush()
# see
# https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
spec = importer.find_spec(module_name)
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)
module = importlib.import_module(module_name)
assert sys.modules[module_name] is module
sys.stdout.write(" succeeded\n")
except (ValueError, AttributeError, TypeError, ImportError):
# we might get error because of cython code that has been
Expand Down
Loading