summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2014-04-13 21:07:04 -0700
committerJoshua Harlow <harlowja@gmail.com>2014-04-13 21:07:04 -0700
commit941c381f0201e99197e0e14fcf304b6107fb6739 (patch)
tree86e8f2f1f9f382f8698ce24ac6ca8263db239da6
parent20fa2f558da4fe12c9539511439f39cf8ad3f2e3 (diff)
downloadsix-941c381f0201e99197e0e14fcf304b6107fb6739.tar.gz
Add a wraps helper
To smooth over the functools wraps difference in python2.x and python3.x add a helper that adds on the __wrapped__ attribute for python2.x (and does nothing in python3.2+). Resolves issue #65
-rw-r--r--six.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/six.py b/six.py
index 6bc97c4..f6f680b 100644
--- a/six.py
+++ b/six.py
@@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
+import functools
import operator
import sys
import types
@@ -631,6 +632,15 @@ if print_ is None:
_add_doc(reraise, """Reraise an exception.""")
+if sys.version_info[0:2] < (3, 2):
+ def wraps(fn):
+ def wrapper(f):
+ f = functools.wraps(fn)(f)
+ f.__wrapped__ = getattr(fn, '__wrapped__', fn)
+ return f
+ return wrapper
+else:
+ wraps = functools.wraps
def with_metaclass(meta, *bases):
"""Create a base class with a metaclass."""