def __init__(self, host=None, port=None, debug=None, debug_file=None, identifier=None, timeout=None, debug_buf_lvl=None):

        self.state = NONAUTH            # IMAP4 protocol state
        self.literal = None             # A literal argument to a command
        self.tagged_commands = {}       # Tagged commands awaiting response
        self.untagged_responses = []    # [[typ: [data, ...]], ...]
        self.mailbox = None             # Current mailbox selected
        self.is_readonly = False        # READ-ONLY desired state
        self.idle_rqb = None            # Server IDLE Request - see _IdleCont
        self.idle_timeout = None        # Must prod server occasionally

        self._expecting_data = False    # Expecting message data
        self._expecting_data_len = 0    # How many characters we expect
        self._accumulated_data = []     # Message data accumulated so far
        self._literal_expected = None   # Message data descriptor

        self.compressor = None          # COMPRESS/DEFLATE if not None
        self.decompressor = None
        self._tls_established = False

        # Create unique tag for this session,
        # and compile tagged response matcher.

        self.tagnum = 0
        self.tagpre = Int2AP(random.randint(4096, 65535))
        self.tagre = re.compile(br'(?P<tag>'
                        + self.tagpre
                        + br'\d+) (?P<type>[A-Z]+) (?P<data>.*)', re.ASCII)

        if __debug__: self._init_debug(debug, debug_file, debug_buf_lvl)

        self.resp_timeout = timeout     # Timeout waiting for command response

        if timeout is not None and READ_POLL_TIMEOUT < timeout:
            self.read_poll_timeout = timeout
        else:
            self.read_poll_timeout = READ_POLL_TIMEOUT
        self.read_size = READ_SIZE

        # Open socket to server.

        self.open(host, port)

        if __debug__:
            if debug:
                self._mesg('connected to %s on port %s' % (self.host, self.port))

        # Threading

        if identifier is not None:
            self.identifier = identifier
        else:
            self.identifier = self.host
        if self.identifier:
            self.identifier += ' '

        self.Terminate = self.TerminateReader = False

        self.state_change_free = threading.Event()
        self.state_change_pending = threading.Lock()
        self.commands_lock = threading.Lock()
        self.idle_lock = threading.Lock()

        self.ouq = queue.Queue(10)
        self.inq = queue.Queue()

        self.wrth = threading.Thread(target=self._writer)
        self.wrth.setDaemon(True)
        self.wrth.start()
        self.rdth = threading.Thread(target=self._reader)
        self.rdth.setDaemon(True)
        self.rdth.start()
        self.inth = threading.Thread(target=self._handler)
        self.inth.setDaemon(True)
        self.inth.start()

        # Get server welcome message,
        # request and store CAPABILITY response.

        try:
            self.welcome = self._request_push(name='welcome', tag='continuation').get_response('IMAP4 protocol error: %s')[1]

            if self._get_untagged_response('PREAUTH'):
                self.state = AUTH
                if __debug__: self._log(1, 'state => AUTH')
            elif self._get_untagged_response('OK'):
                if __debug__: self._log(1, 'state => NONAUTH')
            else:
                raise self.error('unrecognised server welcome message: %s' % repr(self.welcome))

            self._get_capabilities()
            if __debug__: self._log(1, 'CAPABILITY: %r' % (self.capabilities,))

            for version in AllowedVersions:
                if not version in self.capabilities:
                    continue
                self.PROTOCOL_VERSION = version
                break
            else:
                raise self.error('server not IMAP4 compliant')
        except:
            self._close_threads()
            raise
dataset/ETHPy150Open OfflineIMAP/imapfw/imapfw/imap/imaplib3/imaplib2.py/IMAP4.__init__/swapped operands of `<`