def writeToFD(fd, data):
    """
    Write data to file descriptor.

    Returns same thing FileDescriptor.writeSomeData would.

    @type fd: C{int}
    @param fd: non-blocking file descriptor to be written to.
    @type data: C{str} or C{buffer}
    @param data: bytes to write to fd.

    @return: number of bytes written, or CONNECTION_LOST.
    """
    try:
        return os.write(fd, data)
    except (OSError, IOError), io:
        if (errno.EAGAIN, errno.EINTR) in io.errno:
            return 0
        return CONNECTION_LOST
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/internet/fdesc.py/writeToFD/swapped operands of `in`