def _parsing(self):
        """
        Generator to parse bytes into a frame. Yields until
        enough bytes have been read or an error is met.
        """
        buf = b''
        some_bytes = b''

        # yield until we get the first header's byte
        while not some_bytes:
            some_bytes = (yield 1)

        first_byte = some_bytes[0] if isinstance(some_bytes, bytearray) else ord(some_bytes[0])
        # frame-fin = %x0 ; more frames of this message follow
        #           / %x1 ; final frame of this message
        self.fin = (first_byte >> 7) & 1
        self.rsv1 = (first_byte >> 6) & 1
        self.rsv2 = (first_byte >> 5) & 1
        self.rsv3 = (first_byte >> 4) & 1
        self.opcode = first_byte & 0xf

        # frame-rsv1 = %x0 ; 1 bit, MUST be 0 unless negotiated otherwise
        # frame-rsv2 = %x0 ; 1 bit, MUST be 0 unless negotiated otherwise
        # frame-rsv3 = %x0 ; 1 bit, MUST be 0 unless negotiated otherwise
        if self.rsv1 or self.rsv2 or self.rsv3:
            raise ProtocolException()

        # control frames between 3 and 7 as well as above 0xA are currently reserved
        if 2 < self.opcode < 8 or self.opcode > 0xA:
            raise ProtocolException()

        # control frames cannot be fragmented
        if self.opcode > 0x7 and self.fin == 0:
            raise ProtocolException()

        # do we already have enough some_bytes to continue?
        some_bytes = some_bytes[1:] if some_bytes and len(some_bytes) > 1 else b''

        # Yield until we get the second header's byte
        while not some_bytes:
            some_bytes = (yield 1)

        second_byte = some_bytes[0] if isinstance(some_bytes, bytearray) else ord(some_bytes[0])
        mask = (second_byte >> 7) & 1
        self.payload_length = second_byte & 0x7f

        # All control frames MUST have a payload length of 125 some_bytes or less
        if self.opcode > 0x7 and self.payload_length > 125:
            raise FrameTooLargeException()

        if some_bytes and len(some_bytes) > 1:
            buf = some_bytes[1:]
            some_bytes = buf
        else:
            buf = b''
            some_bytes = b''

        if self.payload_length == 127:
            # This will compute the actual application data size
            if len(buf) < 8:
                nxt_buf_size = 8 - len(buf)
                some_bytes = (yield nxt_buf_size)
                some_bytes = buf + (some_bytes or b'')
                while len(some_bytes) < 8:
                    b = (yield 8 - len(some_bytes))
                    if b is not None:
                        some_bytes = some_bytes + b
                if len(some_bytes) > 8:
                    buf = some_bytes[8:]
                    some_bytes = some_bytes[:8]
            else:
                some_bytes = buf[:8]
                buf = buf[8:]
            extended_payload_length = some_bytes
            self.payload_length = unpack(
                '!Q', extended_payload_length)[0]
            if self.payload_length > 0x7FFFFFFFFFFFFFFF:
                raise FrameTooLargeException()
        elif self.payload_length == 126:
            if len(buf) < 2:
                nxt_buf_size = 2 - len(buf)
                some_bytes = (yield nxt_buf_size)
                some_bytes = buf + (some_bytes or b'')
                while len(some_bytes) < 2:
                    b = (yield 2 - len(some_bytes))
                    if b is not None:
                        some_bytes = some_bytes + b
                if len(some_bytes) > 2:
                    buf = some_bytes[2:]
                    some_bytes = some_bytes[:2]
            else:
                some_bytes = buf[:2]
                buf = buf[2:]
            extended_payload_length = some_bytes
            self.payload_length = unpack(
                '!H', extended_payload_length)[0]

        if mask:
            if len(buf) < 4:
                nxt_buf_size = 4 - len(buf)
                some_bytes = (yield nxt_buf_size)
                some_bytes = buf + (some_bytes or b'')
                while not some_bytes or 4 < len(some_bytes):
                    b = (yield 4 - len(some_bytes))
                    if b is not None:
                        some_bytes = some_bytes + b
                if len(some_bytes) > 4:
                    buf = some_bytes[4:]
            else:
                some_bytes = buf[:4]
                buf = buf[4:]
            self.masking_key = some_bytes

        if len(buf) < self.payload_length:
            nxt_buf_size = self.payload_length - len(buf)
            some_bytes = (yield nxt_buf_size)
            some_bytes = buf + (some_bytes or b'')
            while len(some_bytes) < self.payload_length:
                l = self.payload_length - len(some_bytes)
                b = (yield l)
                if b is not None:
                    some_bytes = some_bytes + b
        else:
            if self.payload_length == len(buf):
                some_bytes = buf
            else:
                some_bytes = buf[:self.payload_length]

        self.body = some_bytes
        yield
dataset/ETHPy150Open Lawouach/WebSocket-for-Python/ws4py/framing.py/Frame._parsing/swapped operands of `<`