From b84927aa899412bb58e0498cc0c867fa207583e1 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Tue, 5 Dec 2017 20:41:08 +0100 Subject: [PATCH] Handle deprecation of inspect.getargspec The getargspec function is deprecated in python3 and in some cases the deprecation warning can actually cause unit test failures[1]. Follow Sean's example[2] to smartly use the right inspect function and avoid deprecation warnings. [1] http://logs.openstack.org/47/524747/3/check/openstack-tox-py35/1585cb9/testr_results.html.gz [2] https://review.openstack.org/#/c/521979/ Change-Id: Ia0ac9a79f9faf618aeafae4621afaf1db62ed1e5 --- keystone/common/manager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/keystone/common/manager.py b/keystone/common/manager.py index daec40a8d9..3fcb4e78f4 100644 --- a/keystone/common/manager.py +++ b/keystone/common/manager.py @@ -26,6 +26,11 @@ from keystone.i18n import _ LOG = log.getLogger(__name__) +if hasattr(inspect, 'getfullargspec'): + getargspec = inspect.getfullargspec +else: + getargspec = inspect.getargspec + def response_truncated(f): """Truncate the list returned by the wrapped function. @@ -85,7 +90,7 @@ class _TraceMeta(type): @staticmethod def wrapper(__f, __classname): - __argspec = inspect.getargspec(__f) + __argspec = getargspec(__f) __fn_info = '%(module)s.%(classname)s.%(funcname)s' % { 'module': inspect.getmodule(__f).__name__, 'classname': __classname,