Ejemplo n.º 1
0
def _getargspec(obj):
  """Wrapper for oinspect.getargspec."""
  try:
    argspec = oinspect.getargspec(obj)
  except (TypeError, AttributeError):
    return None
  d = dict(argspec._asdict())
  # Work around py2/py3 argspec differences
  # TODO(b/136556288): Remove this.
  if 'varkw' not in d:
    d['varkw'] = d.pop('keywords')
  return d
Ejemplo n.º 2
0
def _getargspec(obj):
  """Wrapper for oinspect.getargspec.

  This wraps the parent to swallow exceptions.

  Args:
    obj: object whose argspec we return

  Returns:
    The result of getargspec or None.
  """
  try:
    argspec = oinspect.getargspec(obj)
  except (TypeError, AttributeError):
    return None
  if argspec.args and argspec.args[0] == 'self':
    argspec = argspec._replace(args=argspec.args[1:])
  return argspec