Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 00929b9

Browse files
tacaswelljankatins
authored andcommitted
MNT: yet more compatibility fixes
In python > 3.2 `functools.update_wrapper` (which backs the `wraps` decorator) adds `__wrapped__` attribute to the returned function to provide easy access to the base function. Mock this up for legacy versions of python.
1 parent 47ff38a commit 00929b9

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,9 +1590,11 @@ def param(func):
15901590
new_sig = None
15911591
ver_info = sys.version_info
15921592
# py2.6 compatible version, use line below as soon as we can
1593-
_python_has_signature = ver_info[0] > 2 and ver_info[1] > 2
1594-
# _python_has_signature = ver_info.major > 2 and ver_info.minor > 2
1595-
if not _python_has_signature:
1593+
python_has_signature = ver_info[0] > 2 and ver_info[1] > 2
1594+
# python_has_signature = ver_info.major > 2 and ver_info.minor > 2
1595+
python_has_wrapped = ver_info[0] > 2 and ver_info[1] > 1
1596+
# python_has_wrapped = ver_info.major > 2 and ver_info.minor > 1
1597+
if not python_has_signature:
15961598
arg_spec = inspect.getargspec(func)
15971599
_arg_names = arg_spec.args
15981600
_has_no_varargs = arg_spec.varargs is None
@@ -1791,6 +1793,8 @@ def inner(ax, *args, **kwargs):
17911793
_repl = _repl.format(names="', '".join(replace_names))
17921794
inner.__doc__ = (pre_doc +
17931795
_DATA_DOC_APPENDIX.format(replaced=_repl))
1796+
if not python_has_wrapped:
1797+
inner.__wrapped__ = func
17941798
if new_sig is not None:
17951799
inner.__signature__ = new_sig
17961800
return inner

0 commit comments

Comments
 (0)