AttributeError: type object 'sage.misc.lazy_import.LazyImport' has no attribute '__div__'

34 views
Skip to first unread message

Isuru Fernando

unread,
Jun 14, 2020, 2:30:04 PM6/14/20
to sage-devel, sage-pa...@googlegroups.com
I'm trying to package sage 9.1 for conda and I get this error with latest Cython 0.29.20

If I downgrade to Cython 0.29.12, the error goes away. Any ideas?

Isuru

Nils Bruin

unread,
Jun 14, 2020, 4:06:01 PM6/14/20
to sage-devel
On Sunday, June 14, 2020 at 11:30:04 AM UTC-7, Isuru Fernando wrote:
I'm trying to package sage 9.1 for conda and I get this error with latest Cython 0.29.20

If I downgrade to Cython 0.29.12, the error goes away. Any ideas?

I think it would be good to report where the error happens. The idea of lazy_import objects is that their location is rebound to the actual object before serious use. That obviously doesn't happen here, so it's probably a mis-imported lazyimport object. This happen when you, for instance, do

from <module> import lazily_imported_object

See, for instance the discussion in https://trac.sagemath.org/ticket/19628 .

The truth is: the LazyImport wrappers are probably good enough for wrapping functions, but are provably not sufficient for wrapping whole objects (on which you call __div__). So in my opiniion, the fact that you find a lazyimport object on which __div__ is called, is a bug.

Isuru Fernando

unread,
Jun 14, 2020, 4:10:59 PM6/14/20
to sage-devel, sage-pa...@googlegroups.com
Here's the traceback.

Isuru

$sage -c 1+1
SageMath version 9.1, Release Date: 2020-05-20
Traceback (most recent call last):
  File "/home/conda/feedstock_root/build_artifacts/sagelib_1592119926566/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/bin/sage-eval", line 4, in <module>
    from sage.all import *
  File "/home/conda/feedstock_root/build_artifacts/sagelib_1592119926566/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.6/site-packages/sage/all.py", line 117, in <module>
    import sage.misc.lazy_import
  File "sage/misc/lazy_import.pyx", line 1, in init sage.misc.lazy_import (build/cythonized/sage/misc/lazy_import.c:10174)
AttributeError: type object 'sage.misc.lazy_import.LazyImport' has no attribute '__div__'


Nils Bruin

unread,
Jun 14, 2020, 5:20:53 PM6/14/20
to sage-devel
Ah yes, I think this might be due to the fact that __div__ is not a special slot in python3 anymore. Apparently cython 0.29.20 doesn't cover this up anymore, so probably the code discovers it doesn't have anywhere to stick the "__div__" method that's defined on LazyImport" Since 9.2 onwards doesn't need to maintain compatibility with py2, we can get rid of this __div__ method. Possibly it should be replaced with wrappers for the other div methods that have taken its place.

So, while LazyImport gets abused quite a bit in sage, the bug you ran into is probably not due to that (given that the errorsite is the actual import of LazyImport)
Reply all
Reply to author
Forward
0 new messages