Verifies that the provided padding is supported and expands to size n.

  Args:
    padding: One of ALLOWED_PADDINGS, or an iterable of them.
    n: An integer, the size of the desired output list.

  Returns:
    If `padding` is one of ALLOWED_PADDINGS, a tuple of size `n` containing `n`
    copies of `padding`.
    If `padding` is an iterable of ALLOWED_PADDINGS of size `n`, it returns
    `padding(x)`.

  Raises:
    TypeError: If n is not a positive integer; if padding is neither one of
      ALLOWED_PADDINGS nor an iterable of ALLOWED_PADDINGS of size n.

def _fill_and_verify_padding(padding, n):
  """Verifies that the provided padding is supported and expands to size n.

  Args:
    padding: One of ALLOWED_PADDINGS, or an iterable of them.
    n: An integer, the size of the desired output list.

  Returns:
    If `padding` is one of ALLOWED_PADDINGS, a tuple of size `n` containing `n`
    copies of `padding`.
    If `padding` is an iterable of ALLOWED_PADDINGS of size `n`, it returns
    `padding(x)`.

  Raises:
    TypeError: If n is not a positive integer; if padding is neither one of
      ALLOWED_PADDINGS nor an iterable of ALLOWED_PADDINGS of size n.
  """
  if not isinstance(n, numbers.Integral) or n < 1:
    raise TypeError("n must be a positive integer")

  if isinstance(padding, six.string_types) and padding in ALLOWED_PADDINGS:
    return (padding,) * n

  try:
    if len(padding) == n and all(p in ALLOWED_PADDINGS for p in padding):
      return tuple(padding)
  except TypeError:
    pass

  raise TypeError("padding is {}, must be member of '{}' or an iterable of "
                  "these of size {}".format(padding, ALLOWED_PADDINGS, n))