summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGinnis <sean.mcginnis@huawei.com>2017-11-21 12:51:42 -0600
committerSean McGinnis <sean.mcginnis@huawei.com>2017-11-21 12:55:11 -0600
commit1bc2e1f36398591c8f02a14c9e86deef6a1b97f6 (patch)
treefb655f8ac3d0b9fdc9e42efd4081b1fe6cf820f3
parenta9931f3708e86983ae906d0060b111bc41d95e58 (diff)
downloadoslo-policy-1bc2e1f36398591c8f02a14c9e86deef6a1b97f6.tar.gz
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
-rw-r--r--oslo_policy/_checks.py7
1 files changed, 6 insertions, 1 deletions
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: