def InetAtoN(addr_string):
  """Convert ipv6 string to packed bytes.

  Args:
    addr_string: IPv6 address string
  Returns:
    bytestring representing address
  Raises:
    socket.error: on bad IPv6 address format
  """
  if not addr_string:
    raise socket.error("Empty address string")

  if BAD_SINGLE_COLON.match(addr_string):
    raise socket.error("Start or ends with single colon")

  if addr_string == "::":
    return ("0" * 32).decode("hex_codec")

  addr_string = _RemoveV4Ending(addr_string)
  addr_string = _StripLeadingOrTrailingDoubleColons(addr_string)
  addr_string = _ZeroPad(addr_string)

  try:
    return addr_string.decode("hex_codec")
  except __HOLE__:
    raise socket.error("Error decoding: %s" % addr_string)
dataset/ETHPy150Open google/grr/grr/lib/ipv6_utils.py/InetAtoN