From 1bc2e1f36398591c8f02a14c9e86deef6a1b97f6 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Tue, 21 Nov 2017 12:51:42 -0600 Subject: 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 --- oslo_policy/_checks.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/oslo_policy/_checks.py b/oslo_policy/_checks.py index c3031cd..b7e7b91 100644 --- a/oslo_policy/_checks.py +++ b/oslo_policy/_checks.py @@ -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: -- cgit v1.2.1