Replace deprecated inspect function in Python 3

Replace deprecated inspect.getargspec [1] with
inspect.getfullargspec [2], which is not deprecated in Python 3.x

inspect.getargspec is kept for Python 2.x, as the new function is
not available for it.

This was causing keystone unit tests output to be flooded with
deprecation warnings [3]

[1] https://docs.python.org/3/library/inspect.html#inspect.getargspec
[2] https://docs.python.org/3/library/inspect.html#inspect.getfullargspec
[3] http://logs.openstack.org/43/474543/3/check/gate-keystone-python35/ae16a96/console.html.gz#_2017-06-15_22_15_16_925141

Change-Id: Ia37ac562122d6315be1ce1277a6753a9caf15998
This commit is contained in:
Samuel de Medeiros Queiroz 2017-06-19 14:46:15 -04:00
parent 3d65053741
commit a5fa896250
1 changed files with 8 additions and 2 deletions

View File

@ -15,7 +15,13 @@
"""Base class(es) for WSGI Middleware."""
from inspect import getargspec
import six
if six.PY2:
from inspect import getargspec as getfullargspec
else:
from inspect import getfullargspec
import webob.dec
import webob.request
import webob.response
@ -124,7 +130,7 @@ class ConfigurableMiddleware(object):
return response
response = req.get_response(self.application)
(args, varargs, varkw, defaults) = getargspec(self.process_response)
args = getfullargspec(self.process_response)[0]
if 'request' in args:
return self.process_response(response, request=req)
return self.process_response(response)