Bobby Bruce has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/68817?usp=email )

Change subject: python: Replace 'getargspec' with 'signature' in SimObject.py
......................................................................

python: Replace 'getargspec' with 'signature' in SimObject.py

In Python 3.11 'inspect.getargspec' has been removed. It has been marked for
deprecation since 3.5. The SimObject.py class has therefore been rewritten to
use 'inspect.signature' instead.

Change-Id: I9efd831e05e0b1619f366ffe722abb0a072fd519
---
M src/python/m5/SimObject.py
1 file changed, 15 insertions(+), 13 deletions(-)



diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index 6caa532..8cb3d14 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -478,19 +478,21 @@
         return_value_policy = kwargs.get("return_value_policy", None)
         static = kwargs.get("static", False)

-        args, varargs, keywords, defaults = inspect.getargspec(func)
-        if varargs or keywords:
-            raise ValueError(
-                "Wrapped methods must not contain variable arguments"
-            )
-
-        # Create tuples of (argument, default)
-        if defaults:
-            args = args[: -len(defaults)] + list(
-                zip(args[-len(defaults) :], defaults)
-            )
-        # Don't include self in the argument list to PyBind
-        args = args[1:]
+ # Create a list of tuples of (argument, default). The `PyBindMethod`
+        # class expects the `args` argument to be a list of either argument
+ # names, in the case that argument does not have a default value, and + # a tuple of (argument, default) in the casae where an argument does.
+        args = []
+        sig = inspect.signature(func)
+        for param_name in sig.parameters.keys():
+            if param_name is "self":
+                # We don't cound 'self' as an argument in this case.
+                continue
+            param = sig.parameters[param_name]
+            if param.default is param.empty:
+                args.append(param_name)
+            else:
+                args.append((param_name, param.default))

         @wraps(func)
         def cxx_call(self, *args, **kwargs):

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/68817?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I9efd831e05e0b1619f366ffe722abb0a072fd519
Gerrit-Change-Number: 68817
Gerrit-PatchSet: 1
Gerrit-Owner: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to