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 2, 2015
1 parent e787c1a commit cf90a84
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion boilerplate.py
Expand Up @@ -209,7 +209,12 @@ def format_value(value):
mappable = ''

# Get argspec of wrapped function
args, varargs, varkw, defaults = inspect.getargspec(getattr(Axes, func))
if six.PY2:
args, varargs, varkw, defaults = inspect.getargspec(
getattr(Axes, func))
else:
(args, varargs, varkw, defaults, kwonlyargs, kwonlydefs,
annotations) = inspect.getfullargspec(getattr(Axes, 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 cf90a84

Please sign in to comment.