#14017: Determine the correct argspec for python functions defined in cython
files
------------------------------------------------+---------------------------
Reporter: SimonKing | Owner: jason
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.7
Component: misc | Resolution:
Keywords: introspection cython argspec | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Simon King | Merged in:
Dependencies: | Stopgaps:
------------------------------------------------+---------------------------
Comment (by tscrim):
Hey Simon,
Replying to [comment:6 SimonKing]:
> Here is another example I am currently not happy with:
> {{{
> sage: cython("""
> def test():
> return 1
> def f(x,y={test():2},**kwds):pass
> """
> )
> sage: sage_getargspec(f)
> ArgSpec(args=['x', 'y'], varargs=None, keywords='kwds', defaults=({None:
2},))
> }}}
> Hence, the default for 'y' is given as `{None: 2}`, but in fact it
should be `{1: 2}`.
>
> As much as I know, Cython does not make the default values available via
attributes of a function, unlike Python. And even if one would try to find
the actual value by evaluating the string `'{test():2}'` in the module's
name space, things could go terribly wrong.
>
> Is someone reading this? How should we proceed in this situation?
I need a few questions answered before I can have a reasonable answer:
1. When are the argspec functions called, during compile, and roughly by
what?
2. Would this be caught as an error by the cython compiler (or any other
bad syntax for that matter)?
3. Would `_sage_getargspec_from_ast` would parse it correctly?
As a general design note, I would think all `sage_getargspec*` functions
should return the same data in the same format (in regard to [comment:5
your comment here]).
As for the patch, two quick things. Is there any reason to have that large
commented out code block? Also I believe we should try to be python 3
compliant as much as possible, so the exceptions should be `raise
ExceptionType("msg")`.
Thank you,[[BR]]
Travis
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14017#comment:8>
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.