def _ensure_can_send(thing):
    """
    It's easy to accidentally pass in a str instead of bytes when send()ing.
    This gives a more informative message if a ``str`` was accidentally passed
    to a send method.

    """
    if isinstance(thing, str):
        raise ValueError(
            'Cannot send type str. Maybe you left out a ".encode()" somewhere?'
            )
