Skip to content

Commit

Permalink
Use getfullargspec on python3
Browse files Browse the repository at this point in the history
Prefere this over getargspec which will be removed in 3.6. This is the least intrusive change however getfullargspec has been deprecated too. Post 2.0 we should rewrite the code to use signature instead
  • Loading branch information
jenshnielsen committed Sep 15, 2015
1 parent 54ddbe5 commit 22f532e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 5 additions & 2 deletions boilerplate.py
Expand Up @@ -214,8 +214,11 @@ def format_value(value):
has_data = 'data' in inspect.signature(base_func).parameters
work_func = inspect.unwrap(base_func)

args, varargs, varkw, defaults = inspect.getargspec(work_func)

if six.PY2:
args, varargs, varkw, defaults = inspect.getargspec(work_func)
else:
(args, varargs, varkw, defaults, kwonlyargs, kwonlydefs,
annotations) = inspect.getfullargspec(work_func)
args.pop(0) # remove 'self' argument
if defaults is None:
defaults = ()
Expand Down
6 changes: 5 additions & 1 deletion lib/matplotlib/artist.py
Expand Up @@ -1110,7 +1110,11 @@ def _get_setters_and_targets(self):
o = getattr(self.o, name)
if not six.callable(o):
continue
if len(inspect.getargspec(o)[0]) < 2:
if six.PY2:
nargs = len(inspect.getargspec(o)[0])
else:
nargs = len(inspect.getfullargspec(o)[0])
if nargs < 2:
continue
func = o
if self.is_alias(func):
Expand Down
6 changes: 5 additions & 1 deletion lib/matplotlib/patches.py
Expand Up @@ -1781,7 +1781,11 @@ def _pprint_styles(_styles):
_table = [["Class", "Name", "Attrs"]]

for name, cls in sorted(_styles.items()):
args, varargs, varkw, defaults = inspect.getargspec(cls.__init__)
if six.PY2:
args, varargs, varkw, defaults = inspect.getargspec(cls.__init__)
else:
(args, varargs, varkw, defaults, kwonlyargs, kwonlydefs,
annotations) = inspect.getfullargspec(cls.__init__)
if defaults:
args = [(argname, argdefault)
for argname, argdefault in zip(args[1:], defaults)]
Expand Down

0 comments on commit 22f532e

Please sign in to comment.