diff options
author | Raymond Hettinger <python@rcn.com> | 2010-08-08 00:56:52 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-08-08 00:56:52 +0000 |
commit | c6d80c1bef62c996d1a7d3b544a108fef17fbf65 (patch) | |
tree | 69bfd207498ceb86fcec365e074c50c0f752e5fc /Lib/functools.py | |
parent | f56c9cd30d7b7113e32a2562f66cc78a3ec441a3 (diff) | |
download | cpython-git-c6d80c1bef62c996d1a7d3b544a108fef17fbf65.tar.gz |
Issue 8814: functools.wraps() did not copy __annotations__.
Diffstat (limited to 'Lib/functools.py')
-rw-r--r-- | Lib/functools.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index a54f030832..103dd426e3 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -12,7 +12,7 @@ from _functools import partial, reduce # update_wrapper() and wraps() are tools to help write # wrapper functions that can handle naive introspection -WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__doc__') +WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__doc__', '__annotations__') WRAPPER_UPDATES = ('__dict__',) def update_wrapper(wrapper, wrapped, @@ -30,7 +30,8 @@ def update_wrapper(wrapper, function (defaults to functools.WRAPPER_UPDATES) """ for attr in assigned: - setattr(wrapper, attr, getattr(wrapped, attr)) + if hasattr(wrapped, attr): + setattr(wrapper, attr, getattr(wrapped, attr)) for attr in updated: getattr(wrapper, attr).update(getattr(wrapped, attr, {})) # Return the wrapper so this can be used as a decorator via partial() |