Commits

Jason R. Coombs committed d461092

Adding py31compat.functools

Comments (0)

Files changed (3)

 Changes
 -------
 
+0.7
+~~~
+
+* Added py31compat.functools, which provides `wraps` and `update_wrapper` that
+  supply the Python 3.2 __wrapped__ attribute.
+
 0.6
 ~~~
 

py31compat/__init__.py

Empty file added.

py31compat/functools.py

+from __future__ import absolute_import
+
+import functools
+
+# Add the automatic addition of the __wrapped__ attribute when calling
+#  update_wrapper or wraps.
+def update_wrapper(wrapper, wrapped, *args, **kwargs):
+	res = functools.update_wrapper(wrapper, wrapped, *args, **kwargs)
+	res.__wrapped__ = wrapped
+	return res
+
+def wraps(wrapped, *args, **kwargs):
+	return functools.partial(update_wrapper, wrapped=wrapped, *args, **kwargs)