Handle deprecation of inspect.getargspec
getargspec has been deprecated in py3 with plans to remove it in py3.6. The recommendation is to move to inspect.signature, but the results of that call are different than the existing one. There is also getfullargspec available under py3 that was originally deprecated, but for the sake of handling 2/3 code, it has been un-deprecated. This call uses inspect internally, but returns a mostly compatible result with what getargspec did. This handles getargspec deprecation by just using getfullargspec instead if it is available. Change-Id: I3fa2973aa21a64eae33f02c2a55f09fd7d01fd57
This commit is contained in:
parent
a9931f3708
commit
1bc2e1f363
@ -22,6 +22,11 @@ import inspect
|
||||
import six
|
||||
import stevedore
|
||||
|
||||
if hasattr(inspect, 'getfullargspec'):
|
||||
getargspec = inspect.getfullargspec
|
||||
else:
|
||||
getargspec = inspect.getargspec
|
||||
|
||||
registered_checks = {}
|
||||
extension_checks = None
|
||||
|
||||
@ -73,7 +78,7 @@ def _check(rule, target, creds, enforcer, current_rule):
|
||||
|
||||
"""
|
||||
# Evaluate the rule
|
||||
argspec = inspect.getargspec(rule.__call__)
|
||||
argspec = getargspec(rule.__call__)
|
||||
rule_args = [target, creds, enforcer]
|
||||
# Check if the rule argument must be included or not
|
||||
if len(argspec.args) > 4:
|
||||
|
Loading…
Reference in New Issue
Block a user