Ticket #11734: trac11734_sage_wraps_no_sourceread_lambda.proper.patch

File trac11734_sage_wraps_no_sourceread_lambda.proper.patch, 1.4 KB (added by leif, 10 years ago)

"Proper" Mercurial changeset replacement patch.

  • sage/misc/decorators.py

    # HG changeset patch
    # User Julian Rueth <julian.rueth@gmail.com>
    Trac 11734: lambda fix for 11734
    
    diff --git a/sage/misc/decorators.py b/sage/misc/decorators.py
    index 702de97..233dd56 100644
    a b def sage_wraps(wrapped, assigned = WRAPPER_ASSIGNMENTS, updated = WRAPPER_UPDATE 
    109109        4
    110110        sage: t.g.__doc__
    111111        'My little method'
     112
     113    The bug described in #11734 is fixed::
     114
     115        sage: def square(f):
     116        ...     @sage_wraps(f)
     117        ...     def new_f(x):
     118        ...         return f(x)*f(x)
     119        ...     return new_f
     120        sage: f = lambda x:x^2
     121        sage: g = square(f)
     122        sage: g(3) # this line used to fail for some people if these command were manually entered on the sage prompt
     123        81
    112124    """
    113125    #TRAC 9919: Workaround for bug in @update_wrapper when used with
    114126    #non-function callables.
    def sage_wraps(wrapped, assigned = WRAPPER_ASSIGNMENTS, updated = WRAPPER_UPDATE 
    122134        #The attribute _sage_argspec_() is read by Sphinx if present and used
    123135        #as the argspec of the function instead of using reflection.
    124136        from sageinspect import sage_getargspec
    125         argspec = sage_getargspec(wrapped)
    126         wrapper._sage_argspec_ = lambda: argspec
     137        wrapper._sage_argspec_ = lambda: sage_getargspec(wrapped)
    127138        return wrapper
    128139    return f
    129140