def try_rgb(s, default=None):
    """ Try parsing a string into an rgb value (int, int, int),
        where the ints are 0-255 inclusive.
        If None is passed, default is returned.
        On failure, InvalidArg is raised.
    """
    if not s:
        return default
    try:
        r, g, b = (int(x.strip()) for x in s.split(','))
    except ValueError:
        raise InvalidRgb(s)
    if not all(in_range(x, 0, 255) for x in (r, g, b)):
        raise InvalidRgb(s)

    return r, g, b
Try parsing a string into an rgb value (int, int, int),
        where the ints are 0-255 inclusive.
        If None is passed, default is returned.
        On failure, InvalidArg is raised.