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

Prevent circular import of matrix space #34283

Closed
soehms opened this issue Aug 5, 2022 · 14 comments
Closed

Prevent circular import of matrix space #34283

soehms opened this issue Aug 5, 2022 · 14 comments

Comments

@soehms
Copy link
Member

soehms commented Aug 5, 2022

The issue occurs randomly when testing ticket #34185 on a system with the optional package meataxe being present. For example

sage -tp --hide=meataxe src/sage/knots/
Traceback (most recent call last):
  File "/home/sebastian/devel/sage/src/bin/sage-runtests", line 157, in <module>
    err = DC.run()
  File "/home/sebastian/devel/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/doctest/control.py", line 1439, in run
    if f.is_present():
  File "/home/sebastian/devel/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/features/__init__.py", line 182, in is_present
    res = self._is_present()
  File "/home/sebastian/devel/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/features/join_feature.py", line 63, in _is_present
    test = f._is_present()
  File "/home/sebastian/devel/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/features/__init__.py", line 950, in _is_present
    importlib.import_module(self.name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1174, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "sage/matrix/matrix_gfpn_dense.pyx", line 1, in init sage.matrix.matrix_gfpn_dense (build/cythonized/sage/matrix/matrix_gfpn_dense.c:21852)
  File "sage/matrix/matrix_dense.pyx", line 1, in init sage.matrix.matrix_dense (build/cythonized/sage/matrix/matrix_dense.c:7897)
  File "sage/matrix/matrix2.pyx", line 1, in init sage.matrix.matrix2 (build/cythonized/sage/matrix/matrix2.c:127958)
  File "sage/matrix/matrix1.pyx", line 1, in init sage.matrix.matrix1 (build/cythonized/sage/matrix/matrix1.c:25542)
  File "sage/matrix/matrix0.pyx", line 28, in init sage.matrix.matrix0 (build/cythonized/sage/matrix/matrix0.c:45663)
  File "/home/sebastian/devel/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/modules/free_module.py", line 182, in <module>
    import sage.matrix.matrix_space
  File "/home/sebastian/devel/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/matrix/matrix_space.py", line 40, in <module>
    from . import matrix_generic_dense
  File "sage/matrix/matrix_generic_dense.pyx", line 1, in init sage.matrix.matrix_generic_dense (build/cythonized/sage/matrix/matrix_generic_dense.c:6637)
AttributeError: partially initialized module 'sage.matrix.matrix_dense' has no attribute 'Matrix_dense' (most likely due to a circular import)

Of course this also occurs (randomly) with option --hide=all or --hide=optional.

Part of Meta-ticket #33580: make all modules importable without sage.all

Component: doctest framework

Keywords: matrix, space, circular, import

Author: Sebastian Oehms

Branch/Commit: 53d8d11

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/34283

@soehms soehms added this to the sage-9.7 milestone Aug 5, 2022
@soehms
Copy link
Member Author

soehms commented Aug 5, 2022

@soehms
Copy link
Member Author

soehms commented Aug 5, 2022

Commit: d4cf504

@soehms

This comment has been minimized.

@soehms
Copy link
Member Author

soehms commented Aug 5, 2022

Author: Sebastian Oehms

@soehms
Copy link
Member Author

soehms commented Aug 5, 2022

Changed keywords from none to matrix, space, circular, import

@soehms
Copy link
Member Author

soehms commented Aug 5, 2022

New commits:

d4cf50434283: initial

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 5, 2022

comment:3

I would suggest to move the imports even closer to their uses, to match the other imports done in this function

@mkoeppe

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 9, 2022

Changed commit from d4cf504 to 53d8d11

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 9, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

53d8d1134283: fix according to review

@soehms
Copy link
Member Author

soehms commented Aug 9, 2022

comment:6

Replying to @mkoeppe:

I would suggest to move the imports even closer to their uses, to match the other imports done in this function

Done!

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 9, 2022

Reviewer: Matthias Koeppe

@soehms
Copy link
Member Author

soehms commented Aug 10, 2022

comment:8

Thanks!

@vbraun
Copy link
Member

vbraun commented Aug 30, 2022

Changed branch from u/soehms/circular_import_matrix_space_34283 to 53d8d11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants