Skip to content

Commit

Permalink
Update inspect.getargspec (deleted in Python 3.11) to `.getfullargs…
Browse files Browse the repository at this point in the history
…pec`.

PiperOrigin-RevId: 530329819
  • Loading branch information
jburnim committed May 8, 2023
1 parent 04a895d commit 14c180b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,16 @@ def primop(self, f, vars_in=None, vars_out=None):
if vars_in is None:
# Deduce the intended variable names from the argument list of the callee.
# Expected use case: the callee is an inline lambda expression.
args, varargs, keywords, _ = inspect.getargspec(f)
args, varargs, varkw, _, kwonlyargs, _, _ = inspect.getfullargspec(f)
vars_in = []
for arg in args:
for arg in args + kwonlyargs:
if arg in self._locals:
vars_in.append(self._locals[arg])
else:
raise ValueError('Auto-referencing unbound variable {}.'.format(arg))
if varargs is not None:
raise ValueError('Varargs are not supported for primops')
if keywords is not None:
if varkw is not None:
raise ValueError('kwargs are not supported for primops')
for var in vars_in:
if var not in self._var_defs:
Expand Down

0 comments on commit 14c180b

Please sign in to comment.