diff options
Diffstat (limited to 'oslo_db/sqlalchemy/utils.py')
-rw-r--r-- | oslo_db/sqlalchemy/utils.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/oslo_db/sqlalchemy/utils.py b/oslo_db/sqlalchemy/utils.py index 72aa364..1a647b4 100644 --- a/oslo_db/sqlalchemy/utils.py +++ b/oslo_db/sqlalchemy/utils.py @@ -18,6 +18,7 @@ import collections import contextlib +import inspect as pyinspect import itertools import logging import re @@ -1227,6 +1228,25 @@ def suspend_fk_constraints_for_col_alter( ) +def getargspec(fn): + """Inspects a function for its argspec. + + This is to handle a difference between py2/3. The Python 2.x getargspec + call is deprecated in Python 3.x, with the suggestion to use the signature + call instead. + + To keep compatibility with the results, while avoiding deprecation + warnings, this instead will use the getfullargspec instead. + + :param fn: The function to inspect. + :returns: The argspec for the function. + """ + if hasattr(pyinspect, 'getfullargspec'): + return pyinspect.getfullargspec(fn) + + return pyinspect.getargspec(fn) + + class NonCommittingConnectable(object): """A ``Connectable`` substitute which rolls all operations back. |