mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
The wrapped function now uses the same name as the original.
This commit is contained in:
parent
4855c9427c
commit
1f83aa6743
@ -137,11 +137,18 @@ def identical_signature_wrapper(original_function, wrapped_function):
|
||||
Return a function with identical signature as ``original_function``'s which
|
||||
will call the ``wrapped_function``.
|
||||
'''
|
||||
function_def = 'lambda {0}: __wrapped__({0})'.format(
|
||||
context = {'__wrapped__': wrapped_function}
|
||||
function_def = compile(
|
||||
'def {0}({1}):\n'
|
||||
' return __wrapped__({1})'.format(
|
||||
original_function.__name__,
|
||||
inspect.formatargspec(
|
||||
formatvalue=lambda val: '',
|
||||
*inspect.getargspec(original_function)
|
||||
)[1:-1]
|
||||
),
|
||||
'<string>',
|
||||
'exec'
|
||||
)
|
||||
fake_function = eval(function_def, {'__wrapped__': wrapped_function})
|
||||
return wraps(original_function)(fake_function)
|
||||
exec function_def in context
|
||||
return wraps(original_function)(context[original_function.__name__])
|
||||
|
Loading…
Reference in New Issue
Block a user