From 77de7730cfb74beaca1655df6f882c4d4e79d50e Mon Sep 17 00:00:00 2001 From: Abhishek Kapatkar Date: Tue, 21 Jan 2020 15:06:39 -0800 Subject: [PATCH] Use getfullargspec from inspect module for py3 --- pygenie/jobs/utils.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pygenie/jobs/utils.py b/pygenie/jobs/utils.py index 486f3e2..169381e 100644 --- a/pygenie/jobs/utils.py +++ b/pygenie/jobs/utils.py @@ -28,6 +28,13 @@ logger = logging.getLogger('com.netflix.genie.jobs.utils') +try: + getargspec = inspect.getfullargspec +except AttributeError: + # py2 compatible + getargspec = inspect.getargspec + + REPR_APPEND_MODES = { 'append', 'insert' @@ -121,7 +128,7 @@ def wrapper(*args, **kwargs): assert len(args) == 2, 'incorrect arguments to {}()'.format(func.__name__) - attr_name = inspect.getargspec(func).args[1] + attr_name = getargspec(func).args[1] self = args[0] value = args[1] @@ -156,8 +163,7 @@ def wrapper(*args, **kwargs): """Set arg to object's attribute as a string.""" assert len(args) == 2, 'incorrect arguments to {}()'.format(func.__name__) - - attr_name = inspect.getargspec(func).args[1] + attr_name = getargspec(func).args[1] self = args[0] value = args[1]