Ticket #7349: trac_7349-6848-port.patch

File trac_7349-6848-port.patch, 3.2 KB (added by timdumol, 12 years ago)

Ports fixes from #6848 to SageNB

  • sagenb/misc/sageinspect.py

    # HG changeset patch
    # User Tim Dumol <tim@timdumol.com>
    # Date 1256830014 -28800
    # Node ID 06cb472606e7355743a79b3bc2fdfc43a01c129d
    # Parent  d5a514bf7c638a3d3fd5880d57d600978b722cca
    #7349 Port of #6848 fixes to SageNB.
    
    diff -r d5a514bf7c63 -r 06cb472606e7 sagenb/misc/sageinspect.py
    a b  
    224224
    225225        sage: from sage.misc.sageinspect import _sage_getargspec_cython
    226226        sage: _sage_getargspec_cython("def init(self, x=None, base=0):")
    227         (['self', 'x', 'base'], None, None, ('None', '0'))
     227        (['self', 'x', 'base'], None, None, (None, 0))
    228228        sage: _sage_getargspec_cython("def __init__(self, x=None, unsigned int base=0):")
    229         (['self', 'x', 'base'], None, None, ('None', '0'))
     229        (['self', 'x', 'base'], None, None, (None, 0))
    230230
    231231    AUTHOR:
    232232   
     
    266266            argnames.append(argname)
    267267            if len(s) > 1:
    268268                defvalue = s[1]
    269                 # Remove quotes around strings
    270                 defvalue = defvalue.strip('"').strip("'")
    271                 argdefs.append(defvalue)
     269                # eval defvalue so we aren't just returning strings
     270                argdefs.append(eval(defvalue))
    272271
    273272        if len(argdefs) > 0:
    274273            argdefs = tuple(argdefs)
     
    308307    if isclassinstance(obj):
    309308        return inspect.getabsfile(obj.__class__)
    310309    # No go? fall back to inspect.
    311     return inspect.getabsfile(obj)    
     310    return inspect.getabsfile(obj)
    312311
    313312def sage_getargspec(obj):
    314313    r"""
     
    390389        sage: sage_getdef(identity_matrix, 'identity_matrix')
    391390        'identity_matrix(ring, n=0, sparse=False)'
    392391
     392    Check that trac #6848 has been fixed:
     393
     394        sage: sage_getdef(RDF.random_element)
     395        '(min=-1, max=1)'
     396
    393397    If an exception is generated, None is returned instead and the
    394398    exception is suppressed.
    395399       
     
    619623        sage: sage_getsource(sage)
    620624        "...all..."
    621625
    622     A cython function with default arguments::
     626    A cython function with default arguments (one of which is a string)::
    623627   
    624628        sage: sage_getdef(sage.rings.integer.Integer.factor, obj_name='factor')
    625         "factor(algorithm='pari', proof='True', limit='None')"
     629        "factor(algorithm='pari', proof=True, limit=None)"
    626630
    627631    A cython method without an embedded position can lead to surprising errors::
    628632   
     
    658662    Test _sage_getargspec_cython with multiple default arguments and a type::
    659663   
    660664        sage: _sage_getargspec_cython("def init(self, x=None, base=0):")
    661         (['self', 'x', 'base'], None, None, ('None', '0'))
     665        (['self', 'x', 'base'], None, None, (None, 0))
    662666        sage: _sage_getargspec_cython("def __init__(self, x=None, base=0):")
    663         (['self', 'x', 'base'], None, None, ('None', '0'))
     667        (['self', 'x', 'base'], None, None, (None, 0))
    664668        sage: _sage_getargspec_cython("def __init__(self, x=None, unsigned int base=0):")
    665         (['self', 'x', 'base'], None, None, ('None', '0'))
     669        (['self', 'x', 'base'], None, None, (None, 0))
    666670   
    667671    Test _extract_embedded_position:
    668672