summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2013-07-15 11:13:08 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2013-07-15 11:13:08 (GMT)
commit24c05bc1542d9637550d5253306016412e5119d3 (patch)
tree12651b54b5479ed65b5b28506098632b7f796464 /Doc
parent6180a2f45321982386200e20bb323eb4261cf1fb (diff)
downloadcpython-24c05bc1542d9637550d5253306016412e5119d3.zip
cpython-24c05bc1542d9637550d5253306016412e5119d3.tar.gz
cpython-24c05bc1542d9637550d5253306016412e5119d3.tar.bz2
Close issue 17482: don't overwrite __wrapped__
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/functools.rst9
-rw-r--r--Doc/whatsnew/3.4.rst9
2 files changed, 16 insertions, 2 deletions
diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
index 3d70955..2f6d9af 100644
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -306,8 +306,8 @@ The :mod:`functools` module defines the following functions:
To allow access to the original function for introspection and other purposes
(e.g. bypassing a caching decorator such as :func:`lru_cache`), this function
- automatically adds a __wrapped__ attribute to the wrapper that refers to
- the original function.
+ automatically adds a ``__wrapped__`` attribute to the wrapper that refers to
+ the function being wrapped.
The main intended use for this function is in :term:`decorator` functions which
wrap the decorated function and return the wrapper. If the wrapper function is
@@ -330,6 +330,11 @@ The :mod:`functools` module defines the following functions:
.. versionchanged:: 3.2
Missing attributes no longer trigger an :exc:`AttributeError`.
+ .. versionchanged:: 3.4
+ The ``__wrapped__`` attribute now always refers to the wrapped
+ function, even if that function defined a ``__wrapped__`` attribute.
+ (see :issue:`17482`)
+
.. decorator:: wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES)
diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst
index 4068947..2b114f1 100644
--- a/Doc/whatsnew/3.4.rst
+++ b/Doc/whatsnew/3.4.rst
@@ -315,3 +315,12 @@ that may require changes to your code.
found but improperly structured. If you were catching ImportError before and
wish to continue to ignore syntax or decoding issues, catch all three
exceptions now.
+
+* :func:`functools.update_wrapper` and :func:`functools.wraps` now correctly
+ set the ``__wrapped__`` attribute even if the wrapped function had a
+ wrapped attribute set. This means ``__wrapped__`` attributes now correctly
+ link a stack of decorated functions rather than every ``__wrapped__``
+ attribute in the chain referring to the innermost function. Introspection
+ libraries that assumed the previous behaviour was intentional will need to
+ be updated to walk the chain of ``__wrapped__`` attributes to find the
+ innermost function.