Skip to content

Commit

Permalink
gh-39423: Use import_module instead of find_spec
Browse files Browse the repository at this point in the history
    
Otherwise the test would fail with meson editable install. See https://g
ithub.com/sagemath/sage/actions/runs/13003203795/job/36265539648 .

Looks like the function was last changed in #36407. There was no
discussion why the simple implementation is not used.

This is part of the fix for this test. The other part needed is
#39498


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.  (can't really test,
but see #39369)
- [ ] I have updated the documentation and checked the documentation
preview.  (no documentation change)

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
    
URL: #39423
Reported by: user202729
Reviewer(s): Tobias Diez
  • Loading branch information
Release Manager committed Feb 21, 2025
2 parents 870aba2 + ef72c43 commit 897e722
Showing 1 changed file with 3 additions and 7 deletions.
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

0 comments on commit 897e722

Please sign in to comment.