From 07b011b897d8b3825447cff297b5bca397964383 Mon Sep 17 00:00:00 2001 From: William Nelson Date: Thu, 25 Apr 2024 17:30:57 -0700 Subject: [PATCH] Support for Python3.11 Related to #232, uses getfullargspec() for two additional cases where inspect.getargspect() is used if Python3 as getargspec() has been deprecated since 3.0 and removed in 3.11 --- imcsdk/imccoreutils.py | 7 ++++++- imcsdk/imcmo.py | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/imcsdk/imccoreutils.py b/imcsdk/imccoreutils.py index 4808110a..538e1db6 100644 --- a/imcsdk/imccoreutils.py +++ b/imcsdk/imccoreutils.py @@ -195,7 +195,12 @@ def load_mo(elem): mo_class_id = elem.tag mo_class = load_class(mo_class_id) - mo_class_params = inspect.getargspec(mo_class.__init__)[0][2:] + if sys.version_info > (3, 0): + # Python 3 code in this block + mo_class_params = inspect.getfullargspec(mo_class.__init__)[0][2:] + else: + # Python 2 code in this block + mo_class_params = inspect.getargspec(mo_class.__init__)[0][2:] mo_class_param_dict = {} for param in mo_class_params: mo_class_param_dict[param] = elem.attrib[ diff --git a/imcsdk/imcmo.py b/imcsdk/imcmo.py index 0659f7df..ddb215ee 100644 --- a/imcsdk/imcmo.py +++ b/imcsdk/imcmo.py @@ -17,6 +17,7 @@ import logging import os +import sys from . import imcgenutils from . import imccoreutils @@ -658,7 +659,12 @@ def __get_mo_obj(self, class_id): import inspect mo_class = imccoreutils.load_class(class_id) - mo_class_params = inspect.getargspec(mo_class.__init__)[0][2:] + if sys.version_info > (3, 0): + # Python 3 code in this block + mo_class_params = inspect.getfullargspec(mo_class.__init__)[0][2:] + else: + # Python 2 code in this block + mo_class_params = inspect.getargspec(mo_class.__init__)[0][2:] mo_class_param_dict = {} for param in mo_class_params: prop = imccoreutils.get_prop_meta(mo_class, param)