Add 2to3 compatibility for functools.wraps
In order to support compatibility between functools.wraps in version 2 and 3 (3.4 or later) functools.wraps was replaced by six.wraps. The behaviour of sixdecorator is exaclty the same but it also supports __wrapped__ attribute according to 3.4 specs. Change-Id: Ib695629e69e517206e630fff026c08b7847402dc
This commit is contained in:
parent
d08d5c6cdd
commit
3082fbb884
@ -12,7 +12,6 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import functools
|
||||
import itertools
|
||||
|
||||
from oslo_log import log as logging
|
||||
@ -48,7 +47,7 @@ def lb_immutable(exc):
|
||||
|
||||
|
||||
def retry_if_immutable(task):
|
||||
@functools.wraps(task)
|
||||
@six.wraps(task)
|
||||
def wrapper(*args, **kwargs):
|
||||
while True:
|
||||
yield
|
||||
|
@ -11,8 +11,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import functools
|
||||
|
||||
import six
|
||||
from webob import exc
|
||||
|
||||
@ -28,7 +26,7 @@ def policy_enforce(handler):
|
||||
|
||||
This is a handler method decorator.
|
||||
"""
|
||||
@functools.wraps(handler)
|
||||
@six.wraps(handler)
|
||||
def handle_stack_method(controller, req, tenant_id, **kwargs):
|
||||
if req.context.tenant_id != tenant_id:
|
||||
raise exc.HTTPForbidden()
|
||||
@ -48,7 +46,7 @@ def identified_stack(handler):
|
||||
This is a handler method decorator.
|
||||
"""
|
||||
@policy_enforce
|
||||
@functools.wraps(handler)
|
||||
@six.wraps(handler)
|
||||
def handle_stack_method(controller, req, stack_name, stack_id, **kwargs):
|
||||
stack_identity = identifier.HeatIdentifier(req.context.tenant_id,
|
||||
stack_name,
|
||||
|
@ -11,8 +11,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import functools
|
||||
|
||||
from keystoneclient import access
|
||||
from keystoneclient.auth.identity import base
|
||||
from keystoneclient.auth.identity import v3
|
||||
@ -23,6 +21,7 @@ from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
from oslo_middleware import request_id as oslo_request_id
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _LE
|
||||
@ -295,7 +294,7 @@ def ContextMiddleware_filter_factory(global_conf, **local_conf):
|
||||
|
||||
|
||||
def request_context(func):
|
||||
@functools.wraps(func)
|
||||
@six.wraps(func)
|
||||
def wrapped(self, ctx, *args, **kwargs):
|
||||
if ctx is not None and not isinstance(ctx, context.RequestContext):
|
||||
ctx = context.RequestContext.from_dict(ctx.to_dict())
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
"""Heat exception subclasses"""
|
||||
|
||||
import functools
|
||||
import sys
|
||||
|
||||
from oslo_log import log as logging
|
||||
@ -79,7 +78,7 @@ def wrap_exception(notifier=None, publisher_id=None, event_type=None,
|
||||
temp_type = event_type
|
||||
if not temp_type:
|
||||
# If f has multiple decorators, they must use
|
||||
# functools.wraps to ensure the name is
|
||||
# six.wraps to ensure the name is
|
||||
# propagated.
|
||||
temp_type = f.__name__
|
||||
|
||||
@ -89,7 +88,7 @@ def wrap_exception(notifier=None, publisher_id=None, event_type=None,
|
||||
# re-raise original exception since it may have been clobbered
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
|
||||
return functools.wraps(f)(wrapped)
|
||||
return six.wraps(f)(wrapped)
|
||||
return inner
|
||||
|
||||
|
||||
|
@ -281,7 +281,7 @@ def wrappertask(task):
|
||||
self.cleanup()
|
||||
"""
|
||||
|
||||
@functools.wraps(task)
|
||||
@six.wraps(task)
|
||||
def wrapper(*args, **kwargs):
|
||||
parent = task(*args, **kwargs)
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
import functools
|
||||
import json
|
||||
import sys
|
||||
import uuid
|
||||
@ -278,7 +277,7 @@ def stack_context(stack_name, create_res=True):
|
||||
of test success/failure
|
||||
"""
|
||||
def stack_delete(test_fn):
|
||||
@functools.wraps(test_fn)
|
||||
@six.wraps(test_fn)
|
||||
def wrapped_test(test_case, *args, **kwargs):
|
||||
def create_stack():
|
||||
ctx = getattr(test_case, 'ctx', None)
|
||||
|
Loading…
x
Reference in New Issue
Block a user