Replace use of functools.wraps() with six.wraps()

In Python 2.7, functools.wraps() does not provide the '__wrapped__'
attribute. This attribute is used by
oslo_utils.reflection.get_signature() when getting the signature of a
function. If a function is decorated without the '__wrapped__'
attribute then the signature will be of the decorator rather than the
underlying function.

From the six documentation for six.wraps():
    This is exactly the functools.wraps() decorator, but it sets the
    __wrapped__ attribute on what it decorates as functools.wraps()
    does on Python versions after 3.2.

Change-Id: Ic0f7a6be9bc3e474a0229b264d1bfe6c8f7e6d85
This commit is contained in:
John L. Villalovos 2018-02-01 15:15:00 -08:00
parent 7fa0e9f8c3
commit 8873f5eb91
1 changed files with 2 additions and 2 deletions

View File

@ -282,7 +282,7 @@ def async_command(command_name, validator=None):
def async_decorator(func):
func.command_name = command_name
@functools.wraps(func)
@six.wraps(func)
def wrapper(self, **command_params):
# Run a validator before passing everything off to async.
# validators should raise exceptions or return silently.
@ -311,7 +311,7 @@ def sync_command(command_name, validator=None):
def sync_decorator(func):
func.command_name = command_name
@functools.wraps(func)
@six.wraps(func)
def wrapper(self, **command_params):
# Run a validator before invoking the function.
# validators should raise exceptions or return silently.