summaryrefslogtreecommitdiff
path: root/src/tests/documentation.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/documentation.py')
-rw-r--r--src/tests/documentation.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/tests/documentation.py b/src/tests/documentation.py
index e4d99b6..8282063 100644
--- a/src/tests/documentation.py
+++ b/src/tests/documentation.py
@@ -591,9 +591,11 @@ having to rewrite them in terms of ``decorator``. You can use a
$$decorator_apply
-``decorator_apply`` sets the attribute ``.__wrapped__`` of the generated
+``decorator_apply`` sets the attribute ``__wrapped__`` of the generated
function to the original function, so that you can get the right
-source code.
+source code. If you are using Python 3, you should also set the
+``__qualname__`` attribute to preserve the qualified name of the
+original function.
Notice that I am not providing this functionality in the ``decorator``
module directly since I think it is best to rewrite the decorator rather
@@ -1053,9 +1055,9 @@ You can check that the ``__annotations__`` dictionary is preserved:
True
Here ``f.__wrapped__`` is the original undecorated function. Such an attribute
-is added to be consistent with the way `functools.update_wrapper` work.
+is added to be consistent with the way ``functools.update_wrapper`` work.
Another attribute which is copied from the original function is
-`__qualname`, the qualified name. This is a concept introduced
+``__qualname__``, the qualified name. This is a concept introduced
in Python 3. In Python 2 the decorator module will still add a
qualified name, but its value will always be `None`.
"""
@@ -1084,8 +1086,8 @@ def decorator_apply(dec, func):
is not a signature-preserving decorator.
"""
return FunctionMaker.create(
- func, 'return decorated(%(signature)s)',
- dict(decorated=dec(func)), __wrapped__=func)
+ func, 'return decfunc(%(signature)s)',
+ dict(decfunc=dec(func)), __wrapped__=func)
def _trace(f, *args, **kw):