id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,merged,author,reviewer,upstream,work_issues,branch,commit,dependencies,stopgaps
11791,Introspection for interactively defined classes with metaclass,SimonKing,jason,"#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.",enhancement,needs_work,major,sage-6.4,cython,,"introspection, cython, dynamic metaclass",,,Simon King,,N/A,,,,"#11298, #11768, #11734, #11115, #10620, #9107",