If success, return a tuple (args, body)
359257
def parse_func_body(self):
        """"""
        self.save()
        self._expected = []
        if self.next_is_rc(Tokens.OPAR, False):  # do not render right hidden
            self.handle_hidden_right()  # render hidden after new level
            args = self.parse_param_list()
            if args is not None:  # may be an empty table
                if self.next_is_rc(Tokens.CPAR, False):  # do not render right hidden
                    self.handle_hidden_right()  # render hidden after new level
                    body = self.parse_block()
                    if body:
                        self._expected = []
                        token = self.next_is_rc(Tokens.END, False)
                        if token:
                            body.stop_char = token.stop
                            self.success()
                            return args, body
                        else:
                            self.abort()
                else:
                    self.abort()
        return self.failure()
545114
def maybe(func):
    """"""

    name = object_name(func)

    @wraps(func)
    def maybe_wrapped(*args, **kwargs):
        """@maybe wrapped version of ``func``."""
        fails = [
            (name, k, v)
            for k, v in chain(enumerate(args), kwargs.items())
            if isinstance(v, Fail)]

        if fails:
            return Fail(func, fails=fails)

        try:
            result = func(*args, **kwargs)

        except Exception as exc:
            return Fail(func, exception=exc)

        else:
            if isinstance(result, Fail):
                result.add_call(func)

            return result

    return maybe_wrapped
39969
def func_args(func):
    '''
    '''
    try:
        return tuple(inspect.signature(func).parameters)
    except:
        return tuple(inspect.getargspec(func).args)
884626
def equal_args(*args, **kwargs):
  """"""
  key = args
  if kwargs:
    key += _kwargs_separator + tuple(sorted(kwargs.items()))
  return key
11438
def str2tuple(str_in):
    '''
    
    '''
    tuple_out = safe_eval(str_in)
    if not isinstance(tuple_out, tuple):
        tuple_out = None
    return tuple_out
325752
def check_tuple_size(tuples, tuple_size, context):
  """"""
  if tuple_size is not None and tuples.shape[1] != tuple_size:
    msg_t = (("Tuples of {} element(s) expected{}. Got tuples of {} "
             "element(s) instead (shape={}):\ninput={}.\n")
             .format(tuple_size, context, tuples.shape[1], tuples.shape,
                     tuples))
    raise ValueError(msg_t)
1265722
def has_key(tup, key):
  
  if isinstance(tup, framework.TupleLike):
    return tup.is_bound(key)
  if isinstance(tup, dict):
    return key in tup
  if isinstance(tup, list):
    if not isinstance(key, int):
      raise ValueError('Key must be integer when checking list index')
    return key < len(tup)
  raise ValueError('Not a tuple-like object: %r' % tup)
1068751
def postinit(self, args, body):
        
        self.args = args
        self.body = body
684366
def get_tuple(self):
        """"""
        objType, objInstance = self.value

        if isinstance(objType, int):
            pass
        elif isinstance(objType, long):
            objType = int(objType)
        elif isinstance(objType, basestring):
            # turn it back into an integer
            objType = self.objectTypeClass()[objType]
        else:
            raise TypeError("invalid datatype for objType")

        # pack the components together
        return (objType, objInstance)
1194171
def ensure_tuple(obj):
    """"""
    if obj is None:
        return tuple()
    if isinstance(obj, Iterable) and not isinstance(obj, six.string_types):
        return tuple(obj)
    return obj,
617914
def slicing(args, length):
    """"""
    if isinstance(args, tuple):
        for arg in args:
            yield from slicing_singlevalue(arg, length)
    else:
        yield from slicing_singlevalue(args, length)
17996
def getse(op, arg=None):
    
    try:
        return _se[op]
    except KeyError:
        # Continue to opcodes with an effect that depends on arg
        pass

    if arg is None:
        raise ValueError("Opcode stack behaviour depends on arg")

    def get_func_tup(arg, nextra):
        if arg > 0xFFFF:
            raise ValueError("Can only split a two-byte argument")
        return (nextra + 1 + (arg & 0xFF) + 2*((arg >> 8) & 0xFF),
                1)

    if op == CALL_FUNCTION:
        return get_func_tup(arg, 0)
    elif op == CALL_FUNCTION_VAR:
        return get_func_tup(arg, 1)
    elif op == CALL_FUNCTION_KW:
        return get_func_tup(arg, 1)
    elif op == CALL_FUNCTION_VAR_KW:
        return get_func_tup(arg, 2)

    elif op == BUILD_TUPLE:
        return arg, 1
    elif op == BUILD_LIST:
        return arg, 1
    elif python_version == '2.7' and op == BUILD_SET:
        return arg, 1
    elif op == UNPACK_SEQUENCE:
        return 1, arg
    elif op == BUILD_SLICE:
        return arg, 1
    elif op == DUP_TOPX:
        return arg, arg*2
    elif op == RAISE_VARARGS:
        return 1+arg, 1
    elif op == MAKE_FUNCTION:
        return 1+arg, 1
    elif op == MAKE_CLOSURE:
        if python_version == '2.4':
            raise ValueError("The stack effect of MAKE_CLOSURE depends on TOS")
        else:
            return 2+arg, 1
    else:
        raise ValueError("The opcode %r isn't recognized or has a special "
                         "flow control" % op)
39659
def bind(self, fn: Callable[[Any], 'State']) -> 'State':
        
        """

        def _(result: Any, state: Any) -> Tuple[Any, Any]:
            return fn(result).run(state)

        return State(lambda state: _(*self.run(state)))
468639
def _ensure_ifaces_tuple(ifaces):
    """"""
    try:

        ifaces = tuple(ifaces)

    except TypeError:

        ifaces = (ifaces,)

    for iface in ifaces:

        if not _issubclass(iface, ibc.Iface):

            raise TypeError('Can only compare against interfaces.')

    return ifaces
687700
def ensure_tuple(length, tuples):
	
	
	for elem in tuples:
		# Handle non-tuples and non-lists as a single repeated element.
		if not isinstance(elem, (tuple, list)):
			yield (elem, ) * length
			continue
		
		l = len(elem)
		
		# If we have the correct length already, yield it.
		if l == length:
			yield elem
		
		# If we're too long, truncate.
		elif l > length:
			yield tuple(elem[:length])
		
		# If we're too short, pad the *leading* element out.
		elif l < length:
			yield (elem[0], ) * (length - l) + tuple(elem)
43432
def _parse_tuple_string(argument):
        
        if isinstance(argument, str):
            return tuple(int(p.strip()) for p in argument.split(','))
        return argument
1144190
def _structure_tuple(self, obj, tup):
        """"""
        tup_params = tup.__args__
        has_ellipsis = tup_params and tup_params[-1] is Ellipsis
        if tup_params is None or (has_ellipsis and tup_params[0] is Any):
            # Just a Tuple. (No generic information.)
            return tuple(obj)
        if has_ellipsis:
            # We're dealing with a homogenous tuple, Tuple[int, ...]
            tup_type = tup_params[0]
            conv = self._structure_func.dispatch(tup_type)
            return tuple(conv(e, tup_type) for e in obj)
        else:
            # We're dealing with a heterogenous tuple.
            return tuple(
                self._structure_func.dispatch(t)(e, t)
                for t, e in zip(tup_params, obj)
            )