#11791: Introspection for interactively defined classes with metaclass
---------------------------+------------------------------------------------
   Reporter:  SimonKing    |          Owner:  jason                             
      
       Type:  enhancement  |         Status:  new                               
      
   Priority:  major        |      Milestone:  sage-4.7.2                        
      
  Component:  misc         |       Keywords:  introspection, cython, dynamic 
metaclass
Work_issues:               |       Upstream:  N/A                               
      
   Reviewer:               |         Author:  Simon King                        
      
     Merged:               |   Dependencies:  #11298, #11768, #11734            
      
---------------------------+------------------------------------------------
 #11298 provides the possibility to inspect interactive cython code.
 However, the following case did not work:
 {{{
 sage: cython_code = [
 ....: 'from sage.structure.dynamic_class import dynamic_class',
 ....: 'from sage.all import cached_function',
 ....: 'MyMetaclass = dynamic_class("MyMetaclass",(ClasscallMetaclass,))',
 ....: 'class Bar2:',
 ....: '    __metaclass__ = MyMetaclass',
 ....: '    @cached_function',
 ....: '    def __classcall__(cls, R):',
 ....: '        return type.__call__(cls, R)',
 ....: '    def __init__(self,R):',
 ....: '        self.R = R',
 ....: '    def __repr__(self):',
 ....: '        return "[%s]"%self.R',
 ....: '    def __hash__(self):',
 ....: '        print "computing the hash"',
 ....: '        return int(12345)']
 sage: sage: cython('\n'.join(cython_code))
 sage: Bar2??
 }}}
 It would show the code of `ClasscallMetaclass`, not the definition of
 `Bar2`.

 The attached patch fixes it. It is based on cleaning-up
 `sage_getsourcelines`: That function uses different techniques to get the
 source lines, and it turns out that they were attempted in a wrong order.

 The patch also needs #11768, or it wouldn't apply, and #11734, or sage
 would not start.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11791>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to