Merge "Use six.wraps for py2/py3 compat"

This commit is contained in:
Jenkins
2015-02-16 13:22:46 +00:00
committed by Gerrit Code Review
2 changed files with 5 additions and 7 deletions

View File

@@ -17,7 +17,6 @@
import collections
import copy
import datetime
import functools
import logging
import traceback
@@ -155,7 +154,7 @@ class VersionedObjectRegistry(object):
# requested action and the result will be returned here.
def remotable_classmethod(fn):
"""Decorator for remotable classmethods."""
@functools.wraps(fn)
@six.wraps(fn)
def wrapper(cls, context, *args, **kwargs):
if VersionedObject.indirection_api:
result = VersionedObject.indirection_api.object_class_action(
@@ -180,7 +179,7 @@ def remotable_classmethod(fn):
# "orphaned" and remotable methods cannot be called.
def remotable(fn):
"""Decorator for remotable object methods."""
@functools.wraps(fn)
@six.wraps(fn)
def wrapper(self, *args, **kwargs):
ctxt = self._context
if ctxt is None:
@@ -820,5 +819,5 @@ def serialize_args(fn):
# NOTE(danms): Make this discoverable
wrapper.remotable = getattr(fn, 'remotable', False)
wrapper.original_fn = fn
return (functools.wraps(fn)(wrapper) if hasattr(fn, '__call__')
return (six.wraps(fn)(wrapper) if hasattr(fn, '__call__')
else classmethod(wrapper))

View File

@@ -22,7 +22,6 @@ SHOULD include dedicated exception logging.
"""
import functools
import logging
import sys
@@ -80,7 +79,7 @@ def wrap_exception(notifier=None, get_notifier=None):
payload.update({'args': cleansed})
# If f has multiple decorators, they must use
# functools.wraps to ensure the name is
# six.wraps to ensure the name is
# propagated.
event_type = f.__name__
@@ -88,7 +87,7 @@ def wrap_exception(notifier=None, get_notifier=None):
event_type,
payload)
return functools.wraps(f)(wrapped)
return six.wraps(f)(wrapped)
return inner