#14767: Fix import_statements for lazy imported objects
----------------------------+-----------------------------------------------
       Reporter:  tmonteil  |         Owner:  jason       
           Type:  defect    |        Status:  needs_review
       Priority:  major     |     Milestone:  sage-5.11   
      Component:  misc      |    Resolution:              
       Keywords:  days49    |   Work issues:              
Report Upstream:  N/A       |     Reviewers:              
        Authors:            |     Merged in:              
   Dependencies:            |      Stopgaps:              
----------------------------+-----------------------------------------------
Changes (by vdelecroix):

  * status:  new => needs_review


Old description:

> Here is an example:
> {{{
> sage: import_statements('NN')
> from sage.misc.lazy_import import NN
> sage: from sage.misc.lazy_import import NN
> ...
> ImportError: cannot import name NN
> }}}
>
> That's because `NN` is a not-yet-resolved lazy imported object.
>
> However, it is able to answer correctly with a bit of help:
>
> {{{
> sage: import_statements('NN', lazy=True)
> from sage.misc.lazy_import import lazy_import
> lazy_import('sage.misc.lazy_import', 'NN')
> sage: from sage.misc.lazy_import import lazy_import
> sage: lazy_import('sage.misc.lazy_import', 'NN'
> }}}
>
> By the way, the default value for ``lazy`` could possibly be set to
> True for lazy imported objects.

New description:

 Here is an example:
 {{{
 sage: import_statements('NN')
 from sage.misc.lazy_import import NN
 sage: from sage.misc.lazy_import import NN
 ...
 ImportError: cannot import name NN
 }}}

 That's because `NN` is a not-yet-resolved lazy imported object.

 solution 1: the default value for ``lazy`` could possibly be set to True
 for lazy imported objects (original proposition of the ticket)

 solution 2: if the object is a `LazyImport` then get the corresponding
 object with `._get_object`
 (solution implemented in the ticket)

 With the patch applied
 {{{
 sage: import_statements(NN)
 from sage.rings.semirings.non_negative_integer_semiring import NN
 sage: import_statements('NN')
 from sage.rings.semirings.non_negative_integer_semiring import NN
 }}}

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14767#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to