def format_addr(address):
    """Turn a TCP or Unix domain socket address into a string."""
    if isinstance(address, tuple):
        if address[1]:
            return '%s:%d' % address
        else:
            return address[0]

    return address