# 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 
109  109  4 
110  110  sage: t.g.__doc__ 
111  111  '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 
112  124  """ 
113  125  #TRAC 9919: Workaround for bug in @update_wrapper when used with 
114  126  #nonfunction callables. 
… 
… 
def sage_wraps(wrapped, assigned = WRAPPER_ASSIGNMENTS, updated = WRAPPER_UPDATE 
122  134  #The attribute _sage_argspec_() is read by Sphinx if present and used 
123  135  #as the argspec of the function instead of using reflection. 
124  136  from sageinspect import sage_getargspec 
125   argspec = sage_getargspec(wrapped) 
126   wrapper._sage_argspec_ = lambda: argspec 
 137  wrapper._sage_argspec_ = lambda: sage_getargspec(wrapped) 
127  138  return wrapper 
128  139  return f 
129  140  