def wrapping(wrapped):
# A decorator to decorate a decorator's wrapper. Following the lead
# of Twisted and Monocle, this is supposed to make debugging heavily
# decorated code easier. We'll see...
# TODO(pcostello): This copies the functionality of functools.wraps
# following the patch in http://bugs.python.org/issue3445. We can replace
# this once upgrading to python 3.3.
def wrapping_wrapper(wrapper):
try:
wrapper.__wrapped__ = wrapped
wrapper.__name__ = wrapped.__name__
wrapper.__doc__ = wrapped.__doc__
wrapper.__dict__.update(wrapped.__dict__)
# Local functions won't have __module__ attribute.
if hasattr(wrapped, '__module__'):
wrapper.__module__ = wrapped.__module__
except Exception:
pass
return wrapper
return wrapping_wrapper
# Define a base class for classes that need to be thread-local.
# This is pretty subtle; we want to use threading.local if threading
# is supported, but object if it is not.
评论列表
文章目录