def _decode(b):
    """
    Internal decode function (see decode()).

    RETURN VALUE:
      A tuple (slen: int, s: bytes) where slen is the length of the data in bytes and s is the initial buffer with length and colon removed.

    THROWS:
      ValueError if the provided bytes object does not begin with a valid netstring
  """
    slen, s = b.split(b':', 1)
    slen = int(slen.decode('ascii'))
    if slen < 0 or s[slen] != b','[0]:
        raise ValueError
    return slen, s
