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

Skip to content

Commit 22f532e

Browse files
committed
Use getfullargspec on python3
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
1 parent 54ddbe5 commit 22f532e

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

boilerplate.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,11 @@ def format_value(value):
214214
has_data = 'data' in inspect.signature(base_func).parameters
215215
work_func = inspect.unwrap(base_func)
216216

217-
args, varargs, varkw, defaults = inspect.getargspec(work_func)
218-
217+
if six.PY2:
218+
args, varargs, varkw, defaults = inspect.getargspec(work_func)
219+
else:
220+
(args, varargs, varkw, defaults, kwonlyargs, kwonlydefs,
221+
annotations) = inspect.getfullargspec(work_func)
219222
args.pop(0) # remove 'self' argument
220223
if defaults is None:
221224
defaults = ()

lib/matplotlib/artist.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,11 @@ def _get_setters_and_targets(self):
11101110
o = getattr(self.o, name)
11111111
if not six.callable(o):
11121112
continue
1113-
if len(inspect.getargspec(o)[0]) < 2:
1113+
if six.PY2:
1114+
nargs = len(inspect.getargspec(o)[0])
1115+
else:
1116+
nargs = len(inspect.getfullargspec(o)[0])
1117+
if nargs < 2:
11141118
continue
11151119
func = o
11161120
if self.is_alias(func):

lib/matplotlib/patches.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,11 @@ def _pprint_styles(_styles):
17811781
_table = [["Class", "Name", "Attrs"]]
17821782

17831783
for name, cls in sorted(_styles.items()):
1784-
args, varargs, varkw, defaults = inspect.getargspec(cls.__init__)
1784+
if six.PY2:
1785+
args, varargs, varkw, defaults = inspect.getargspec(cls.__init__)
1786+
else:
1787+
(args, varargs, varkw, defaults, kwonlyargs, kwonlydefs,
1788+
annotations) = inspect.getfullargspec(cls.__init__)
17851789
if defaults:
17861790
args = [(argname, argdefault)
17871791
for argname, argdefault in zip(args[1:], defaults)]

0 commit comments

Comments
 (0)