Browse Source

remove inspect.getargspec deprecation warning

In python 3 inspect.getargspec is deprecated and
replaced with inspect.getfullargspec which does not
exist on python 2.7. This change uses six to select
the correct version to use based on the python version
used.

Change-Id: I234a3509ff850d0c5616ebcfa240212b03db9e76
Closes-Bug: #1814288
changes/18/682518/1 0.13.0
Sean Mooney 2 years ago
parent
commit
5d1f322542
  1. 10
      migrate/versioning/script/py.py

10
migrate/versioning/script/py.py

@ -141,8 +141,14 @@ class PythonScript(base.BaseScript):
script_func = self._func(funcname)
# check for old way of using engine
if not inspect.getargspec(script_func)[0]:
raise TypeError("upgrade/downgrade functions must accept engine"
arg_spec = None
if six.PY2:
arg_spec = inspect.getargspec(script_func)
else:
arg_spec = inspect.getfullargspec(script_func)
if not arg_spec[0]:
raise TypeError(
"upgrade/downgrade functions must accept engine"
" parameter (since version 0.5.4)")
script_func(engine)

Loading…
Cancel
Save