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
This commit is contained in:
Colleen Murphy 2017-12-05 20:41:08 +01:00
parent 51d5b63a08
commit b84927aa89
1 changed files with 6 additions and 1 deletions

View File

@ -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,