Skip to content

Commit cbf5906

Browse files
committed
Use import_module instead of find_spec
1 parent dc99dc8 commit cbf5906

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/sage/misc/dev_tools.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
171171
load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
172172
"""
173173
from .package_dir import walk_packages
174-
import importlib.util
174+
import importlib
175175

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

0 commit comments

Comments
 (0)