diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2013-07-15 11:13:08 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2013-07-15 11:13:08 (GMT) |
commit | 24c05bc1542d9637550d5253306016412e5119d3 (patch) | |
tree | 12651b54b5479ed65b5b28506098632b7f796464 /Lib/functools.py | |
parent | 6180a2f45321982386200e20bb323eb4261cf1fb (diff) | |
download | cpython-24c05bc1542d9637550d5253306016412e5119d3.zip cpython-24c05bc1542d9637550d5253306016412e5119d3.tar.gz cpython-24c05bc1542d9637550d5253306016412e5119d3.tar.bz2 |
Close issue 17482: don't overwrite __wrapped__
Diffstat (limited to 'Lib/functools.py')
-rw-r--r-- | Lib/functools.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index 6aa13a2..19f88c7 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -55,7 +55,6 @@ def update_wrapper(wrapper, are updated with the corresponding attribute from the wrapped function (defaults to functools.WRAPPER_UPDATES) """ - wrapper.__wrapped__ = wrapped for attr in assigned: try: value = getattr(wrapped, attr) @@ -65,6 +64,9 @@ def update_wrapper(wrapper, setattr(wrapper, attr, value) for attr in updated: getattr(wrapper, attr).update(getattr(wrapped, attr, {})) + # Issue #17482: set __wrapped__ last so we don't inadvertently copy it + # from the wrapped function when updating __dict__ + wrapper.__wrapped__ = wrapped # Return the wrapper so this can be used as a decorator via partial() return wrapper |