From 5d1f322542cd8eb42381612765be4ed9ca8105ec Mon Sep 17 00:00:00 2001 From: Sean Mooney Date: Tue, 17 Sep 2019 02:05:19 +0100 Subject: [PATCH] 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 --- migrate/versioning/script/py.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/migrate/versioning/script/py.py b/migrate/versioning/script/py.py index 92a8f6b..e323b40 100644 --- a/migrate/versioning/script/py.py +++ b/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)